fluent-nhibernate

Will my session be automatically closed?

天涯浪子 提交于 2019-12-25 04:37:19
问题 Edit Orignal Title: My transaction is closed by the time it gets to my Repo. What am I doing wrong? I got a answer to my origanl questions(I forgot to open the transaction lol). Now I am wondering if my code is automatically closing the session or if I have to somehow tell it to do this. Hi I am using mvc 3.0, nhibernate, fluent nhibernate and ninject 2.0 Global.asax // Note: For instructions on enabling IIS6 or IIS7 classic mode, // visit http://go.microsoft.com/?LinkId=9394801 public class

Fluent Nhibernate Many to Many relationship issue

删除回忆录丶 提交于 2019-12-25 04:22:59
问题 I have a situation where I have three tables in our database. One to contain customers, one contains customer groups, and then a table to link them together. I am having issues where my nHibernate query wont join them correctly, and I am not sure if I am missing something. Mapping for the Customer Groups public CustomerGroupMapping() { Table("tbCustomerGroups"); // TODO: Revisit Lazy loading //LazyLoad(); Id(x => x.customerGroupId) .GeneratedBy.Identity() .Column("Customer_Group_ID"); Map(x =

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

fluent nhibernate foreign key with 2 columns mapping

别来无恙 提交于 2019-12-25 02:59:58
问题 I have to an existing schema and I want to map it with nhibernate. entities / table schema: post { pk_id prod_id prod_internid title } tag { pk_t_id prod_id prod_internid name } A post can have multiple tags and there is a foreign key contraint from the tag to the post table with the two columns prod_id and prod_internid. I've tried this: PostMap { // tags is a list HasMany(x => x.tags).KeyColumns.Add("prod_id", "prod_internid"); } TagMap { References(x => x.post).Columns("prod_id", "prod

Losing the record ID

拜拜、爱过 提交于 2019-12-25 02:55:46
问题 I have a record structure where I have a parent record with many children records. On the same page I will have a couple queries to get all the children. A later query I will get a record set when I expand it it shows "Proxy". That is fine an all for getting data from the record since everything is generally there. Only problem I have is when I go to grab the record "ID" it is always "0" since it is proxy. This makes it pretty tough when building a dropdown list where I use the record ID as

One-to-one Mapping issue with NHibernate/Fluent: Foreign Key not updateing

梦想与她 提交于 2019-12-25 02:44:51
问题 Summary: Parent and Child class. One to one relationship between the Parent and Child. Parent has a FK property which references the primary key of the Child. Code as follows: public class NHTestParent { public virtual Guid NHTestParentId { get; set; } public virtual Guid ChildId { get { return ChildRef.NHTestChildId; } set { } } public virtual string ParentName { get; set; } protected NHTestChild _childRef; public virtual NHTestChild ChildRef { get { if (_childRef == null) _childRef = new

NHibernate mapping multiple relationships between two tables

你。 提交于 2019-12-25 02:31:09
问题 I have an irritating problem. I've got two objects which are related on two different columns. The relationships are the same (both one-Many) and the structure is as follows BRAND table ID Name [Other stuff] CATEGORY table ID Name BrandID (FK to Brand. Navigation Name Brands) DynamicBrandID (FK to Brand. Navigation Name DynamicBrands [Other stuff] But no matter what I try, I can't get this to work in NHibernate. The HBM files look like they've generated correctly for both objects but no

fluent nhibernate - Many to Many relationship with attribute on relationship

大兔子大兔子 提交于 2019-12-25 02:14:09
问题 I have my code working, but I'm getting 2 extra columns in the table/ddl, to represent a Many to Many relationship, ~~but~~ with attributes (scalars) on the relationship. I am using 1.2.0.712 (FluentNHibernate.dll) 3.1.0.4000 (NHibernate.dll) Entities: public partial class Employee { public Employee() { CommonConstructor(); } private void CommonConstructor() { this.MyEmployeeToJobTitleMatchLinks = new List<EmployeeToJobTitleMatchLink>(); } public virtual Guid? EmployeeUUID { get; set; }

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