I'm trying to map an interface and concrete class with fluentnhibernate.
here's my interface / class:
public interface IUser
{
int Id { get; set; }
}
public class User: IUser
{
public int Id { get; set; }
public string Name { get; set; }
public string Password { get; set; }
}
here's my mapping files:
public class IUserM...
Hi All,
I found a fantastic template for NHibernate code generation using MyGeneration here,
http://vucetica.blogspot.com/2009/01/nhibernate-template-for-mygeneration.html
This creates XML mapping files with the extension hbm.xml.
I was wonder if anybody knows of templates which support fluent NHibernate which defines the mapping usi...
I have two tables in my database "Styles" and "BannedStyles". They have a reference via the ItemNo. Now styles can be banned per store. So if style x is banned at store Y then its very possible that its not banned at store Z or vice verse. What is the best way now to map this to a single entity? Should I be mapping this to a single entit...
Hello!
I've got a problem with fluent nhibernate table per class hierarchy mapping. I've got 2 domain objects, container (baseclass) and album (subclass). Album only contains a constructor. Container dervies from EntityWithTypedId from Sharp Architect. EntityWithTypedId provides the key of type Guid (the name is ContainerId).
public cl...
Having successfully gotten a sample program working, I'm now starting
to do Real Work with Fluent NHibernate - trying to use Automapping on my project's class
heirarchy.
It's a scientific instrumentation application, and the classes I'm
mapping have several properties that are arrays of floats e.g.
private float[] _rawY;
...
Apologies if this was already asked but, I have had a look and can't find anything. I am trying to work out the best way to model the following in C#. I have sketched out a few idea but none of them feel right.
I have created an abstract 'Person' class. My application will have Clients and Employees.
Obviously,
A Client is a Person
An ...
I have a WPF app that lets the user select an image from a file dialog.
The same app opens a SQLite database with Fluent NHibernate (auto mapping).
I try to convert the image to byte array and save it, but for some reason it's not doing it and for some other reason I see my db file in the image folder.
Any one knows how to fix this?
...
We have a fairly robust system using NHibernate, we're in the middle of migrating from a single database server to having two servers, one for administration and one for our public facing web site. This is mainly so that we can do things like content management with workflow that won’t affect the current site. As of today, they are tw...
Hi, I'm trying to convert my data layer from Linq2Sql to nHibernate. I think Xml the configuration in nHibernate is pretty backwards so I'm using Fluent.
I've managed to get fluent, add in a repository pattern and unit of work pattern, and my unit tests are looking good.
However now as I'm plugging it into my services layer I'm noticin...
hello,
i'm trying to understand how and if its possible to keep a session open on a wcf service.
the problem is that if i select an entity and pass it to the client and than return it to the server with the same session, i get an exception cause session dont know this entity any more (the reference changed because of wcf).
so i have t...
Hello...
I have my class X :
public class ClassX
{
public virtual IList<ClassY> ListY { get; set; }
...
}
My ClassX mapping (using Fluent)
...
HasMany<ClassX>(x => x.ListY )
.Inverse()
.Cascade.AllDeleteOrphan()
.KeyColumns.Add("`IDX`");
...
My Y class:
public class ClassY
{
...
public...
Hi All,
I am working with NHibernate, and a few code generation tools. MyGeneration is one and SmartCode is the other.
This question has been asked before, but I have looked at some other responses and found that the code generation tools in the nHibernate space to be pretty poor.
I might be able to get away with MyGeneration and Smar...
Let's say I have an existing database with the following 3 tables:
Table1:
(PK)T1ID1
(PK)T1ID2
Table2:
(PK)T2ID1
Table3:
(FK)T1ID1
(FK)T1ID2
(FK)T2ID1
(Where the 3 keys come from the tables above)
My question is: How do I map Table3 with Fluent NHibernate?
What is confusing to me is what to do about the fact that its composite keys c...
I have a legacy DB which uses a guid to map children to the parent entity.
In my domain layer, I'd prefer to obscure this quirk, so I'd like to have my parent entity look like this:
public class Parent
{
virtual public int Id {get; protected set; }
virtual public string ParentContent { get; set; }
virtual public Guid Refer...
I'm trying to map inheritance with discriminator, but subclasses don't have discriminator value. How to solve it using AutoMappings?
Domain objects are as following:
public abstract class Item : GuidIdentityEntity {
public virtual string Name { get; set; }
}
public class Product : Item {}
public class RawMaterial : Item {}
Config...
I'm trying to write a Compare method to compare properties in some POCOs using Reflection to ensure that they've been persisted to the database correctly. For example, let's say I have this POCO:
public class NoahsArk
{
public string Owner { get; set; }
public ICollection<Animal> Animals { get; set; }
}
What I want to do is th...
Hi,
Im making the switch from Fluent Mapping to Automapping in my current project.
If I have the following domain:
public class Matter{
public Client Client{get;set;}
}
public class Client {
public Name Name{get;set;}
}
public class Name{
public string FirstName{get;set;}
public string LastName{get;set;}
}
When Autom...
Hi,
We have the following situation:
Consider a Contract object that has a GUID primary key and a unique key (for legacy issues). This Contract should be mapped on the Contracts table.
Now, we have Operation, which has a GUID primary key, the unique key of the contract, and other properties. For each contract there are many operations. W...
Hi
I have an entity:
public class Message:Entity
{
public virtual IList<Message> ReplayMessages { set; get; }
public virtual Message ParentMessage { set; get; }
}
I try to override the mapping:
mapping.HasMany(x => x.ReplayMessages)
.AsSet()
.KeyColumnNames.Add("ParentId");
but i...
Hi.
I want to create a many to many relationship, but I want to have in the new table(MessageReceivers) a unique contraint on both columns (AdvanceMessageId,UserId):
mapping.HasManyToMany(x => x.Receivers)
.WithParentKeyColumn("AdvanceMessageId")
.WithChildKeyColumn("UserId")
.Cascade.All(...