automapping

How can you create Clustered Indexes with Fluent NHibernate?

天涯浪子 提交于 2019-11-29 08:24:24
I am using Fluent-NHibernate (with automapping) to generate my tables but would like to choose a different clustered index than the ID field which is used by default. How can you create clustered indexes with Fluent NHibernate on a field other than the default Primary Key field? The primary reasoning behind this is simple. I am using Guids for my primary key fields. By default, NHibernate creates clustered indexes on the primary key fields. Since Guids are usually not sequential, clustering on the primary key field causes a performance issue. As we all know, appending records at the end of a

C# - IDataReader to Object mapping using generics

时光怂恿深爱的人放手 提交于 2019-11-29 04:01:52
How can I map a DataReader object into a class object by using generics? For example I need to do the following: public class Mapper<T> { public static List<T> MapObject(IDataReader dr) { List<T> objects = new List<T>(); while (dr.Read()) { //Mapping goes here... } return objects; } } And later I need to call this class-method like the following: IDataReder dataReader = DBUtil.Fetchdata("SELECT * FROM Book"); List<Book> bookList = Mapper<Book>.MapObject(dataReder); foreach (Book b in bookList) { Console.WriteLine(b.ID + ", " + b.BookName); } Note that, the Mapper - class should be able to map

Fluent NHIbernate automapping of List<string>?

廉价感情. 提交于 2019-11-28 23:33:00
Fluent NHibernate doesn't like this, throwing an error: {"Association references unmapped class: System.String"} OK fine, I can see why this would cause a problem - but what's the best solution? I don't really want it to store a delimited list of strings in a single field, this would get ugly if my list contains many strings. I also don't really want a table 'string', for obvious reasons. I guess I can solve this by wrapping my List<string> inside a class, but this feels a little heavyweight. I'm starting to think its the best solution though. What's the best way to get Fluent NHibernate to

Cascade Saves with Fluent NHibernate AutoMapping

吃可爱长大的小学妹 提交于 2019-11-28 22:00:49
问题 How do I "turn on" cascading saves using AutoMap Persistence Model with Fluent NHibernate? As in: I Save the Person and the Arm should also be saved. Currently I get "object references an unsaved transient instance - save the transient instance before flushing" public class Person : DomainEntity { public virtual Arm LeftArm { get; set; } } public class Arm : DomainEntity { public virtual int Size { get; set; } } I found an article on this topic, but it seems to be outdated. 回答1: This works

Eager Loading Using Fluent NHibernate/Nhibernate & Automapping

好久不见. 提交于 2019-11-28 19:17:15
I have a requirement to load a complex object called Node ...well its not that complex...it looks like follows:- A Node has a reference to EntityType which has a one to many with Property which in turn has a one to many with PorpertyListValue public class Node { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual EntityType Etype { get; set; } } public class EntityType { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual IList<Property> Properties { get; protected set; } public EntityType() { Properties = new List

How do you automap List<float> or float[] with Fluent NHibernate?

核能气质少年 提交于 2019-11-28 13:04:40
Having successfully gotten a sample program working, I'm now starting to do Real Work with Fluent NHibernate - trying to use Automapping on my project's class heirarchy. It's a scientific instrumentation application, and the classes I'm mapping have several properties that are arrays of floats e.g. private float[] _rawY; public virtual float[] RawY { get { return _rawY; } set { _rawY = value; } } These arrays can contain a maximum of 500 values. I didn't expect Automapping to work on arrays, but tried it anyway, with some success at first. Each array was auto mapped to a BLOB (using SQLite),

Override for fluent NHibernate for long text strings nvarchar(MAX) not nvarchar(255)

℡╲_俬逩灬. 提交于 2019-11-28 07:58:51
When ever you set a string value in fluent NHibernate it alwasy sets the DB vales to Nvarchar(255), I need to store quite a lot of long string which are based on user inputs and 255 is impractical. Just to add this is an issue with the automapper as I am using fluent NHibernate to build the database. Lachlan Roche Adding this convention will set the default length for string properties to 10000. As others have noted, this will be a nvarchar(max) column. public class StringColumnLengthConvention : IPropertyConvention, IPropertyConventionAcceptance { public void Accept(IAcceptanceCriteria

How can you create Clustered Indexes with Fluent NHibernate?

微笑、不失礼 提交于 2019-11-28 01:49:26
问题 I am using Fluent-NHibernate (with automapping) to generate my tables but would like to choose a different clustered index than the ID field which is used by default. How can you create clustered indexes with Fluent NHibernate on a field other than the default Primary Key field? The primary reasoning behind this is simple. I am using Guids for my primary key fields. By default, NHibernate creates clustered indexes on the primary key fields. Since Guids are usually not sequential, clustering

Eager Loading Using Fluent NHibernate/Nhibernate & Automapping

杀马特。学长 韩版系。学妹 提交于 2019-11-27 20:32:39
问题 I have a requirement to load a complex object called Node ...well its not that complex...it looks like follows:- A Node has a reference to EntityType which has a one to many with Property which in turn has a one to many with PorpertyListValue public class Node { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual EntityType Etype { get; set; } } public class EntityType { public virtual int Id { get; set; } public virtual string Name { get; set; } public

How do you automap List<float> or float[] with Fluent NHibernate?

谁都会走 提交于 2019-11-27 07:28:47
问题 Having successfully gotten a sample program working, I'm now starting to do Real Work with Fluent NHibernate - trying to use Automapping on my project's class heirarchy. It's a scientific instrumentation application, and the classes I'm mapping have several properties that are arrays of floats e.g. private float[] _rawY; public virtual float[] RawY { get { return _rawY; } set { _rawY = value; } } These arrays can contain a maximum of 500 values. I didn't expect Automapping to work on arrays,