fluent-nhibernate

Override default Fluent NHibernate Column Mapping

I am trying to find the syntax for changing the automap behavior of Fluent NHibernate. How would I modify the code below to map the UserId property to a column named UserIdentifier (as an example)? public class MyTypeMap : ClassMap<MyType> { public MyTypeMap() { Table("MyTypes"); Id(x => x.InstanceId).Ge...

Fluent NHIbernate automapping of List<string> ?

Fluent NHibernate doesnt like this, throwing an error '{"Association references unmapped class: System.String"}'. Ok fine, I can see why this would cause a problem - but whats the best solution? I dont 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 do...

Fluent NHibernate DiscriminateSubClassesOnColumn Issue

I said Fluent NHibernate in the subject, but I think this is an NHibernate question. However, I didn't want to confuse things by leaving out details. I'm using Fluent NHibernate 1.0.0.593 with NHibernate 2.1.0.4000. First a little background... I have a base class with three implementation classes that I'm trying to map using the Di...

How do I map a dictionary using Fluent NHibernate automapping?

I have an entity like so: public class Land { public virtual IDictionary<string, int> Damages { get; set; } // and other properties } Every time I try to use automapping with the following code: var sessionFactory = Fluently.Configure() .Database(SQLiteConfiguration.Standard.InMemory) .Mappings(m => m.AutoMappings.Add...

How do I map an optional one-to-one relationship with Fluent NHibernate?

I've got two entities, one called Site and the other called Assignment. A Site may or may not have an associated Assignment. An Assignment is only ever associated with one Site. In terms of C#, Site has a property of type Assignment which could hold a null reference. I have got two tables by the same names in the database. The Assignmen...

How do you build extensible data model

Hi, 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. ...

Fluent NHibernate table per subclass inheritance mapping

I'm new to NHibernate and Fluent NHibernate. I'm wondering how to properly use Fluent NHibernate with the "table per subclass" mapping strategy. This is an example of what I'm after. More specifically though, I need a way to break the subclass mappings into separate files. Also, when adding records, I need NHibernate to first insert in...

nhibernate Dynamic Insert fails with some null Component properties

I have a database that accepts no null values and has a default for every field. Using fluent nHibernate, I am getting an error on an Insert if I have a component that has some, but not all properties filled out. I am just wondering how to get the DynamicInsert flag down to the component level. Perhaps it is late, but I'll just drop t...

FluentNHibernate SQLite default config ProxyFactoryFactory

Hello I want a simple unit test configuration. My understanding is that the sqlite fluent config defaults to Castle, and I have a reference set to NHibernate.ByteCode.Castle.dll, yet I am getting an error saying there is no ProxyFactory setting set. What am I missing? Cheers, Berryl === the CODE === public abstract class InMemoryDat...

Experience with fluent interfaces? I need your opinion!

Sorry for this long question, it is flagged wiki since I'm asking for something that might not have a very concrete answer. If it is closed, so be it. My main question is this: How would you write a fluent interface that isn't fully defined in the base classes, so that programs that uses the fluent interfaces can tack on new words i...

Best practices writing unit tests with NHibernate

I'm new to NHibernate (+Fluent), and I can't decide on what's the best strategy when it comes to structuring my code to make it testable. I have a plain structure including a domain model, mappings to map the model to database, and a few classes with behavior which will work towards the model classes and do transactions for updating and ...

Cascade on delete using unidirectional Many-To-Many mapping

I am using Fluent and NHibernate. I have two objects say A & B which has a many-to-many relationship between them. I am using a unidirectional many-to-many mapping when A HasMany B's. There is no reference in B about A (Unidirectional). This creates a third table (named ABMapping) in the Database which has the two columns relating to pr...

fluent nhibernate truncate string automatically

Is there an easy way to automatically truncate strings using fluent nHibernate mappings. I would prefer to not address this the setters or a custom type, but with something in the mapping files. ...

NHibernate slow mapping

My question is what can I do to determine the cause of the slowness, or what can I do to speed it up without knowing the exact cause. I am running a simple query and it appears that the mapping back to the entities is taking taking forever. The result set is 350, which is not much data in my opinion. IRepository repo = ObjectFactory.G...

Is it possible to use a Fluent NHibernate convention to map all ICollections as sets?

Is it possible to use a Fluent NHibernate convention to map all ICollections as sets? I have an entity like so: public class NoahsArk { public virtual ICollection<Animal> Animals { get; set; } public NoahsArk() { Animals = new HashSet<Animal>(); } } With fluent mappings, this property would be mapped as HasMan...

Custom Id column in the Fluent NH entity name

I am using S#arp architecture with Fluent Nhibernate and Automapper on a legacy DB. The id column of one of the tables is different from the Automapping convention and therefore I tried to override it without success. I end up with this error FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete config...

How do I use the guid.comb strategy in a MySql db.

Is it possible to use the guid.comb strategy for identity generation with Mysql Db using Nhibernate? When I use it as mapping.Id(x => x.Id) .Column("row_guid") .CustomType(typeof(string)) .GeneratedBy.GuidComb() .Length(36); I end up with a ----> System.InvalidOperationException : Identi...

Cascade issue when deleting an entity in a one-to-one relationship using Fluent NHibernate.

I have the following db tables which I have simplified for this example: Webpage Id, URLIdentifier WebpageMetaData Webpage_id Keywords Webpage_id is the primary key for the table and a foriegn key back to the webpage table. I am then using Fluent NHibernate and its automapping feature to map these to the following POCO classes: publ...

How to test a persistence layer correctly?

Hi! I read the Book NHibernate in Action and there it is speaking about testing the persistence layer/data abstraction layer. You can test two ways. The mapping-test and the persistence logic-test. Accoring to the book testing the mapping means that entities are correctly loaded and saved. But what's about update's and delete's? By no...

Map to Serializable in Fluent NHibernate

NHibernate has a "Serializable" type <property name="PropertyName" column="ColumnName" type="**Serializable**" /> Is there a built in type for this in Fluent NHibernate? Something like Map(x => x.PropertyName).CustomType<**SerializableType**>(); ?? ...