fluent-nhibernate-mapping

How can I map to a joined subclass with a different column than the id of parent?

别来无恙 提交于 2020-01-03 09:14:23
问题 I am working with a brownfield database and am trying to configure a subclass map which joins to its subclasses with a column other than that of the specified id. The login table has a primary key column login_sk which I'd like to use as its id. It joins to two tables via a login_cust_id column (to make things more fun the corresponding columns in the adjoining tables are named differently). If I setup login_cust_id as the id of the UserMap it joins to its subclasses as expected. For what I

Fluent NHibernate Inheritance mapping type

£可爱£侵袭症+ 提交于 2020-01-03 01:58:07
问题 I'm new to Fluent NHibernate, thus far I managed to get my mapping working except for the inheritance part. Is there anybody who could help me finish the mapping? I have simplified the code as much as possible. Thank you! My database: CREATE TABLE [User] ( UserID INT NOT NULL IDENTITY(1,1), Type CHAR(1) NOT NULL, Email VARCHAR(255) NOT NULL, PRIMARY KEY(UserID) ); CREATE TABLE [Student] ( UserID INT NOT NULL, Firstname VARCHAR(255) NOT NULL, PRIMARY KEY(UserID), FOREIGN KEY(UserID) REFERENCES

NHibernate exception: could not initialize a collection, Invalid column name. Fluent mapping. Maybe a many-to-one issue?

妖精的绣舞 提交于 2020-01-02 06:25:30
问题 I am puzzled and frustrated by an exception I'm getting via NHibernate. I apologize for the length of this post, but I've tried to include an appropriate level of detail to explain the issue well enough to get some help! Here's the facts: I have a Person class which contains a property BillingManager , which is also a Person type. I map this as an FNH "Reference". I have an ExpenseReport class which contains a property SubmittedBy , which is a Person type. I map this as an FNH "Reference". I

NHibernate + fluent mapping + NLog = No mapped documents found in assembly

落爺英雄遲暮 提交于 2019-12-25 18:44:09
问题 I've successfully used the CommonLogging layer in NHibernate to log its internal messages using NLog for previous projects which were using hbm.xml files. I'm now switching to fluent mapping, and the NHibernate logs now only contain one line: [Log entry: Warn] 2019-02-01 13:30:42.5537 No mapped documents found in assembly: <assembly name> I also tried to move the nhibernate-logger configuration directive from the App.config file to the code, just after configuring the mapping – and I'm

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

Fluent nHibernate map HasMany to Entity/Table with no Primary Key

亡梦爱人 提交于 2019-12-25 03:47:08
问题 I am having the worst trouble trying to setup a HasMany relationship to an entity backed by a table with no primary key. ClassA has a CompositeId . To circumvent the lack of a primary key on ClassB , I tried to create a CompositeId on ClassB that was comprised all of the columns in the table. No matter what I've tried, nothing has worked. These are my classes and mappings. public class ClassA { public virtual int a_1_id {get;set;} public virtual string a_2_id {get;set;} public virtual IList

Fluent nhibernate m-to-m mapping with external table

谁说胖子不能爱 提交于 2019-12-25 03:18:05
问题 I have two tables in Oracle Entity ---------- **EntityId** NUMBER(9), **EntityName** VARCHAR2 EntityLinks -------------- **EntityLinkId** NUMBER(9),**ParentEntityId** NUMBER(9), **ChildEntityId** NUMBER(9) Table EntityLinks will store ManyToMany relationship between various entities. ParentEntityId and ChildEntityId are having foreign key relationship with Entity . I have below a below class for Entity as well public class Entity { public virtual int EntityId {get; set} public virtual IList

Specifiying Default Value for Datetime property in FluenNhibernate mapping class

一笑奈何 提交于 2019-12-25 02:06:14
问题 imagine we have an object have a property: //the date which app has been added to the system public virtual DateTime SubmitionDate { get; set; } how can I set default value (current date) for SubmutionDate in the sqlServer 2008 using mapping class? I did like this but it doesn't work and raise an sqlDateTimeException! Map(x => x.SubmitionDate).Default(System.DateTime.Now.ToString()).Not.Nullable(); 回答1: The mapping is being processed only when your session factory is being created. Therefore

fluent nHibernate: How to persist a property which is mapped with Formula?

自闭症网瘾萝莉.ら 提交于 2019-12-24 10:31:06
问题 I am dealing with a legacy database, and we have a field which doesn't make sense anymore, but I would rather not change the DB schema. I'm trying to map an old DB text field into a class with a boolean (only need to know about one option that the DB text field has). I can get the boolean value out of the DB using Forumla, but I can seem to get it to save any updates back into the DB. My class and current fluent mapping for it is: public class Bulletin { public virtual int Id { get; set;}

Fluent NHibernate - IndexOutOfRange

…衆ロ難τιáo~ 提交于 2019-12-23 10:01:23
问题 I've read all the posts and know that IndexOutOfRange usually happens because a column is being referenced twice. But I don't see how that's happening based on my mappings. With SHOW_SQL true in the config, I see an Insert into the Events table and then an IndexOutOfRangeException that refers to the RadioButtonQuestions table. I can't see the SQL it's trying to use that generates the exception. I tried using AutoMapping and have now switched to full ClassMap for these two classes to try to