fluent-nhibernate

Fluent NHibernate - Map 2 tables to one class

℡╲_俬逩灬. 提交于 2019-12-18 04:44:11
问题 I have a table structure something like this table Employees EmployeeID EmployeeLogin EmployeeCustID table Customers CustomerID CustomerName What i would like is to map the structure above to one single class named: Class Employee EmployeeID EmployeeLogin EmployeeName How do i do that with fluent nhibernate ? 回答1: I don't know if it is possible with fluent, but in xml you use the join element: simplified: <class name="Employee" table="Customers" > <id name="CustomerID" .../> <property name=

Fluent nHibernate: one-to-many relationship Issue

…衆ロ難τιáo~ 提交于 2019-12-18 03:49:25
问题 I have a problem with one-to-many relationships. I have the following domain classes: public class Installation : Entity<Installation> { public virtual string Name { get; set; } public virtual IList<Institution> Institutions { get; set; } public Installation() { Institutions = new List<Institution>(); } } public class Institution : Entity { public virtual string Name { get; set; } public virtual string Address { get; set; } public virtual string City { get; set; } public virtual Installation

How do you build extensible data model

a 夏天 提交于 2019-12-18 03:48:08
问题 I'm thinking of building a ecommerce application with an extensible data model using NHibernate and Fluent NHibernate. By having an extensible data model, I have the ability to define a Product entity, and allow a user in the application to extend it with new fields/properties with different data types including custom data types. Example: Product can have an addition fields like: Size - int Color - string Price - decimal Collection of ColoredImage - name, image (e.g. "Red", red.jpg (binary

How to map IDictionary<string, Entity> in Fluent NHibernate

大城市里の小女人 提交于 2019-12-18 03:37:13
问题 I have an class with an IDictionary on it. <map name="CodedExamples" table="tOwnedCodedExample"> <key> <column name="OwnerClassID"/> </key> <index type="string" column="ExampleCode"/> <many-to-many class="CodedExample" column ="CodedExampleClassID"/> </map> as you can see it uses a many-to-many to get the CodedExamples from their table using the tOwnedCodedExample table to find which are owned by the OwnerClass. I realise that this is a very basic (and hopefully standard) mapping but am

NHibernate: Select one to Many Left Join - Take X latest from Parent

人盡茶涼 提交于 2019-12-17 21:59:59
问题 I have the following objects: Parent public virtual Guid Id { get; set; } public virtual DateTime TimeStamp { get; set; } public virtual IList<Child> Childs { get; set; } Child public virtual Guid Id { get; set; } public virtual string Name { get; set; } I use Fluent to Map One To Many as follows: .Override<Parent>(obj =>obj.HasMany(x => x.Childs) .Cascade.All() .Not.Inverse() .Not.KeyNullable() .Not.KeyUpdate()) I need to get up to all Parent with Childs between dates order by TimeStamp. I

Runtime error when trying to run Fluent NHibernate tutorial example

烈酒焚心 提交于 2019-12-17 21:34:32
问题 I worked through the Fluent NHibernate tutorial at http://wiki.fluentnhibernate.org/Getting_started and the project compiles fine. However, I am getting a runtime error and I can't seem to resolve it. The error is happening in the CreateSessionFactory method you can see in the tutorial. Here it is: private static ISessionFactory CreateSessionFactory() { return Fluently.Configure() .Database ( SQLiteConfiguration.Standard .UsingFile(DbFile) ) .Mappings(m => m.FluentMappings.AddFromAssemblyOf

nhibernate: using parts of the compositeId in a ManyToOne Property

♀尐吖头ヾ 提交于 2019-12-17 21:20:05
问题 I have a tablestructure like this: Table entity ( otherEntity_id int // primarykey id int // primarykey parent_id int ) and class public class Entity { public OtherEntity Other { get; set; } // simple int to discriminate different Entity for the same OtherEntity public int Id { get; set; } public Entity Parent { get; set; } } is it possible to map this to the class Entity? (if yes how) the following throws on save, because there are not enough columns in the dbcommand, one is used twice:

Fluent NHibernate Column Mapping with Reserved Word

怎甘沉沦 提交于 2019-12-17 20:44:33
问题 I've read that using a back tick ` should allow for using of reserved words. I'm using SQL Server and Fluent NHibernate and have a column name "File". If I map it with "`File" it tries using [Fil] so it's adding the brackets correctly, but dropping the "e" from the end. If I map it as "`Filee" it uses [File] correctly. Am I doing something wrong or is this a bug in NHibernate or Fluent Nhibernate? 回答1: You need to put ` on both sides, like this: "`File`" As @Astaar says, the full syntax is:

NHibernate L2 Cache configuration in Fluent NHibernate

早过忘川 提交于 2019-12-17 17:55:17
问题 Is ti possible to configure the L2 cache provider in code via FHN? Adding a line to the following config is what I'm after: return Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(c => c.FromConnectionStringWithKey("Temp")).ShowSql()) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<IMap>()) .ExposeConfiguration(c => { }) .BuildSessionFactory(); Cheers AWC 回答1: This is possible from FNH, in the example below see the 'Cache' property: return Fluently.Configure

DateTime precision in NHibernate and support for DateTime2 in NHibernate SchemeExport

廉价感情. 提交于 2019-12-17 11:27:14
问题 I am then using Fluent NHibernate and its automapping feature to map the the following simplified POCO class: public class Foo { public virtual int Id { get; set; } public virtual datetime CreatedDateTime { get; set; } } The CreatedDateTime field will map to a SQL DateTime by default. However if I do a test to check that the entity is being created correctly it fails. This is because the precision of the DateTime field is not maintained through to the SQL database. I undersatnd the reason