fluent-nhibernate

Mapping enum with fluent nhibernate

走远了吗. 提交于 2019-12-29 03:51:26
问题 I am following the http://wiki.fluentnhibernate.org/Getting_started tutorial to create my first NHibernate project with Fluent NHibernate I have 2 tables 1) Account with fields Id AccountHolderName AccountTypeId 2) AccountType with fields Id AccountTypeName Right now the account types can be Savings or Current So the table AccountTypes stores 2 rows 1 - Savings 2 - Current For AccoutType table I have defined enum public enum AccountType { Savings=1, Current=2 } For Account table I define the

How to create a Multi-Column Index or Unique Constraint with NHibernate

非 Y 不嫁゛ 提交于 2019-12-28 05:51:45
问题 How to create a Multi-Column Index and/or Unique Constraint using NHibernate Mapping or Fluent NHibernate. 回答1: assign a index/unique constraint name to more then one property <property name="A" index="AB" /> <property name="B" index="AB" /> Theoretical it would also work with having more then one index on the same entity: <property name="A" index="AB, ABC" /> <property name="B" index="AB, ABC" /> <property name="C" index="ABC" /> But there is a bug. I also wrote a patch. if you are

NHibernate configuration for uni-directional one-to-many relation

橙三吉。 提交于 2019-12-28 02:44:19
问题 I'm trying to set up a relationship as follows. Each Master item has one or more Detail items: public class Detail { public virtual Guid DetailId { get; set; } public virtual string Name { get; set; } } public class Master { public virtual Guid MasterId { get; set; } public virtual string Name { get; set; } public virtual IList<Detail> Details { get; set; } } And Mappings: public class MasterMap : ClassMap<Master> { public MasterMap() { Id(x => x.MasterId); Map(x => x.Name); HasMany(x => x

How do I map a collection accessed through a read only property?

∥☆過路亽.° 提交于 2019-12-25 16:58:54
问题 How do I map the collection of Parts using a convention? public class Part { public virtual int Id { get; set; } public virtual string Name { get; set; } } public class Car { private readonly List<Part> _parts = new List<Part>(); public virtual int Id { get; set; } public virtual IList<Part> Parts { get { return _parts.AsReadOnly(); } } } I have tried this convention but it always expects the field name without an underscore prefix: public class HasManyConvention : IHasManyConvention { public

NHibernate parent-childs save redundant sql update executed

痞子三分冷 提交于 2019-12-25 16:40:01
问题 I'm trying to save (insert) parent object with a collection of child objects, all objects are new. I prefer to manually specify what to save\update and when so I do not use any cascade saves in mappings and flush sessions by myself. So basically I save this object graph like: session.Save(Parent) foreach (var child in Parent.Childs) { session.Save(child); } session.Flush() I expect this code to insert Parent row, then each child row, however NHibernate executes this SQL: INSERT INTO PARENT...

Fluent nHibernate with Automapping: How to get a parent or “containg” object from a child

让人想犯罪 __ 提交于 2019-12-25 16:19:10
问题 I have an object model similar to this: public class Item { public virtual Guid Id { get; set; } } public class Box { public virtual Guid Id { get; set; } public virtual IList<Item> Contents { get; protected set; } public Box() { Contents = new List<Item>(); } } What I want to do is be able to get an Item's parent (being the box it is in). Normally I would create a field on the Item called Parent and handle the one-to-many relationship in a manual mapping, but we are trying to use automapping

Setting up Fluent NHibernate and StructureMap for a web application

不羁岁月 提交于 2019-12-25 11:56:07
问题 I use this approuch http://www.kevinwilliampang.com/2010/04/06/setting-up-asp-net-mvc-with-fluent-nhibernate-and-structuremap/ for setting up fnh with structuremap but after one request I get the following exception Session is closed! Object name: 'ISession'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System

How to save to a file the Fluent nHibernate 1.1 HBM XML configuration?

旧时模样 提交于 2019-12-25 11:45:12
问题 I am having a issue with it as described here: Fluent NHibernate 1.1: when multiple column name mappings are used on different classes As someone pointed, I need to see the HBM XML configuration to help to debug. I have a config FluentConfiguration config object working: config.Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly())); How to save to a file the Fluent nHibernate 1.1 HBM XML configuration? 回答1: I found a way: config.Mappings(m => m.FluentMappings

Fluent-NHibernate Multi-Level Inheritance based on another column

心已入冬 提交于 2019-12-25 06:59:49
问题 I am having issues finding good documentation for the problem I am having. I am reconstructing a portion of an enterprise solution and swapping over the NHibernate for our ORM. I have 3 tables which I want to all inherit from each other. MasterAccount : Account : InvBilling **MasterAccount** id_MasterAccount **Account** id_Account id_MasterAccount id_InvBilling **InvBilling** id_InvBilling id_MasterAccount For each row in MasterAccount there exists a row in Account where the Id_MasterAccount

Upgraded NHibernate and FNH DLLs - now getting “No persister” exceptions

房东的猫 提交于 2019-12-25 06:52:46
问题 I'm trying to upgrade my FNH Automapping project to the latest versions of NHibernate and Fluent NHibernate (NH 3.2 and FNH 1.3), but now I get a "no persister" exception on a derived class (though the base class still seems to be persisted properly). This derived class Automapped fine with the old dlls (FNH 1.0, NH 2.1.2) - I have not changed my mapping logic or these classes in any way. I upgraded my project by just copying the new dlls over the old ones, and deleting references to dlls