nhibernate-mapping

NHibernate explicit fluent column mapping

我们两清 提交于 2020-01-23 13:18:25
问题 I have a set of fluent object mappings that looks like this: public class UserMap : ClassMap<User> { public UserMap() { Map(x => x.Id); Map(x => x.Status); } } public class SpecialUserMap : SubClassMap<SpecialUser> { public SpecialUserMap() { Map(x => x.Property); } } public class DirectoryMap : ClassMap<Directory> { public DirectoryMap { Map(x => x.Id); HasMany(x => x.SpecialUsers).Where("Status = 0"); } } User is a join table, which SpecialUser joins against to get things like status.

NHibernate explicit fluent column mapping

六眼飞鱼酱① 提交于 2020-01-23 13:18:09
问题 I have a set of fluent object mappings that looks like this: public class UserMap : ClassMap<User> { public UserMap() { Map(x => x.Id); Map(x => x.Status); } } public class SpecialUserMap : SubClassMap<SpecialUser> { public SpecialUserMap() { Map(x => x.Property); } } public class DirectoryMap : ClassMap<Directory> { public DirectoryMap { Map(x => x.Id); HasMany(x => x.SpecialUsers).Where("Status = 0"); } } User is a join table, which SpecialUser joins against to get things like status.

NHibernate insert generates updates for collection items

给你一囗甜甜゛ 提交于 2020-01-16 17:36:58
问题 How should I configure my mappings to avoid NHibernate updating my child entities' foreign keys right after inserting them? E.g. Parent class is mapped like this: class ParentMap : ClassMap<Parent> { public ParentMap() { Id(x => x.Id) .GeneratedBy.Increment(); Map(x => x.Name); HasMany(x => x.ChildNodes) .KeyColumns.Add("Parent_id") .Cascade.All(); } } Let Parent have a bunch of Child objects: Parent p = new Parent("test"); p.ChildNodes.AddRange(GetSomeDummyNodes()); When I save the parent

Setting CustomSqlType on References

一个人想着一个人 提交于 2020-01-16 06:12:49
问题 I have a situation where my primary key is a char(2) in SqlServer 2008, and I want to reference it in a one-to-many relationship, but the ManyToOneBuilder (which is returned by ClassMap<>.References()) doesn't have a CustomSqlType() method. Specifically: public class State { // state FIPS code is 2 characters public virtual string StateCode { get; set; } public virtual ICollection<County> { get; set; } } public class County { // state-county FIPS code is 5 characters public virtual string

NHibernate.Mapping.Attributes.Filter

倾然丶 夕夏残阳落幕 提交于 2020-01-15 12:13:32
问题 I'm mapping my database tables using NHibernate with NHibernate.Mapping.Attributes library and I got stuck to get the Filter attributes to work. Suppose a class A that has a set of objects of class B. So, I have, the following: [NHibernate.Mapping.Attributes.Set(0, Inverse = true, Lazy = NHibernate.Mapping.Attributes.CollectionLazy.False)] [NHibernate.Mapping.Attributes.Key(1, Column = "ClassAId")] [NHibernate.Mapping.Attributes.OneToMany(2, Class = "ClassB, Assembly")] public virtual ISet

NHibernate.Mapping.Attributes.Filter

杀马特。学长 韩版系。学妹 提交于 2020-01-15 12:13:03
问题 I'm mapping my database tables using NHibernate with NHibernate.Mapping.Attributes library and I got stuck to get the Filter attributes to work. Suppose a class A that has a set of objects of class B. So, I have, the following: [NHibernate.Mapping.Attributes.Set(0, Inverse = true, Lazy = NHibernate.Mapping.Attributes.CollectionLazy.False)] [NHibernate.Mapping.Attributes.Key(1, Column = "ClassAId")] [NHibernate.Mapping.Attributes.OneToMany(2, Class = "ClassB, Assembly")] public virtual ISet

Avoid N+1 Select with list of NHibernate entities

◇◆丶佛笑我妖孽 提交于 2020-01-15 05:51:06
问题 I receive a list of NHibernate entities that were retrieved by code that I cannot modify. I want to select a property from a child entity for each item in the list, but it is generating a new select for each item. How can I get the sub-resources without changing the query that generated the entities passed in or changing the mapping (both of which would have an impact on unrelated code). Ideally, I wouldn't have to create a custom query at this layer of my code either. Here is a sample. My

FluentNHibernate or port to NHibernate mapping by code

这一生的挚爱 提交于 2020-01-14 08:07:08
问题 I have several projects using NH and FNH to generate the mappings (some Fluent some Automapped). There are still some bugs and missing features i need, but it seems that FNH could die because of mapping-by-code integrated into NHibernate. Question: Contribute to FNH or to migrate the mappings to mapping-by-code or confORM and fixing problems/implementing features there? 回答1: At our office, we have been using NHibernate for 3 years now. We've been thinking about making a move to Fluent

Fluent NHibernate Visual Designer [closed]

北城余情 提交于 2020-01-13 10:22:11
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Is there a visual designer similar to Mindscape's NHibernate designer for Fluent NHibernate? I have decided to move from EF4 to NH3, but without a visual design interface it is going to be a hard sell to my team who are used to the EF4 model creation interface. 回答1: I've only heard of Mindscape's NHibernate

Fluent NHibernate Visual Designer [closed]

风流意气都作罢 提交于 2020-01-13 10:22:05
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Is there a visual designer similar to Mindscape's NHibernate designer for Fluent NHibernate? I have decided to move from EF4 to NH3, but without a visual design interface it is going to be a hard sell to my team who are used to the EF4 model creation interface. 回答1: I've only heard of Mindscape's NHibernate