fluent-nhibernate

Can I trust NHibernate Fluent Automappings?

I am currently testing using NHibernate Fluent Automappings to map my domain objects and create my database schema. Is this a good or bad idea? ...

fluent nhibernate HasOne WithForeignKey not working

Whenever I load a Task class, the Document property is always null, despite there being data in the db. Task class: public class Task { public virtual Document Document { get; set; } Task Mapping override for AutoPersistenceModel: public void Override(AutoMap<Task> mapping) { mapping.HasOne(x => x.Document) .WithFore...

Fluent Nhibernate Schema Generation

Hi, I have been playing about with FluentNhibernate as part of the S#arp Architecture. Below is an example mapping. public class EventBaseMap : ClassMap<EventBase> { public EventBaseMap() { WithTable("Event_Header"); //NotLazyLoaded(); Id(x => x.Id).WithUnsavedValue(-1).GeneratedBy.Native(); M...

Fluent NHibnernate HasManyToMany with Index

I'm trying to map a many-to-many collection with Fluent NHibnernate. My model class has this property: public virtual IList Screenshots { get { return _screenshots; } protected set { _screenshots = value; } } And my fluent mapping is: HasManyToMany(x => x.Screenshots) .AsList(x => x.WithColumn("Index")) ...

Multiple Levels of Children Entity Objects in Fluent NHibernate/NHibernate

Hi, I have a entity which has a list of Child1 objects. The mappings seem to work fine for this. If I try to add a list of Child2 objects to the Child1 entity and set up the mapping a xml mapping doesn't seem to get created and I get this error: Test method vRATest.ORMTest.NHibernateTests.NHibernate_Should_Be_Able_To_Get_All_Rout...

NHibernate with fluent mapping and Syscache2 second level caching

I have a very simple Country entity which I want to cache. This works perfectly, but I want a clone version of the cached instance to be returned or be made read-only to prevent developers from changing the state of it. How would I achieve this? I tought that the Fluent Readonly() method would enforce this, but it's not the case. Sa...

NHibernate Fluent Automapping Across DLLs

I have a Person class in 1 project/dll and a StandardUser class that derives from Person in another project/dll. I have a Password class that contains a StandardUser (Password and StandardUser are in the same dll). I can't seem to get the fluent automapping to work with this scenario. It tells me: NHibernate.MappingException: An as...

Fluent NHibernate - HasMany().WithKeyColumnName

I just got the latest version of Fluent from Google code and it seems some of the mapping has changed since I last used it. Previously I could Map a relationship using the following when the id I was joining on had a different name in the second table HasMany(x=> x.Roles).WithTableName("tbl_Roles").WithKeyColumn("RoleId"); How is don...

Fluent NHibernate HasMany() problems

I am new to Nhibernate and fluent nHibernate so i'm sure I'm missing something obvious. My problem is I have a class with a IList<> that just won't load. My class is Customer and it has a IList< CustomerImage>. My Customer class loads properly except for this list. Mapping: CustomerMap :ClassMap< Customer> { Id(x => x.CustId).TheCol...

How can I map a private property in my base class?

Using fluent nhibernate, is it possible to map a private property in a base class? I have this defined in my base class: private DateTime? lastModifiedDT { get; set; } but when I map it like so: Version(Reveal.Property<EntityType>("lastModifiedDT")).ColumnName("LastModifiedDT"); I get a FluentNHibernate.UnknownPropertyException ...

FluentNHibernate: Getting the Examples.FirstProject to work

Im trying to get the most basic of examples to run in FnH. I started with the Examples.FirstProject. However, I did not use the SQL lite configuration. Instead, I set the configuration to SQL2005 and created the tables as was diagramed in the example. When stepping through the code, there appears to be no problems when creating the...

NHibernate Fluent vs. Attributes

I'm interested in moving some NHibernate configurations/mappings into the code to help with some maintenance issues. Can anyone provide any advice/pros/cons/comparisons of Fluent NHibernate vs. NHibernate.Mapping.Attributes? I have some experience with Java Hibernate annotations, which I liked, but I'm curious if the NHibernate attribu...

Null value objects in NHibernate

I have a person entity containing an Address as a value object: public Person() { WithTable("Person"); Id(x => x.Id); Component<Address>(x => x.Address, a => { a.Map(x => x.Address1); a.Map(x => x.Address2); a.Map(x => x.Address3); a.Map(x => x.Town); a.Map(x => x.Postcode); }); } It states...

NHibernate ManyToMany relationship that includes all of one side of the relationship

Given this db schema (it was handed down to me): I'd like suggestions on how to both model this and map it using fluent-nhibernate. The only thing I can come up with is a very active record style of modeling (a class for each table and the obvious associations). Ignoring the db for a second though, I think I want every facility to a...

'Table with concrete class' mapping using Fluent NHibernate's auto mapping

Does anyone whether it is possible to configure Fluent NHibernate to auto-map objects using 'Table with concrete class' inheritance. On looking at the auto-mappings (which I had written to file) I have a number of entities that derive from EntityBase but I would like the Id column to be on each table rather than on an EntityBase table....

Identical on NH but Unique on SQL server

Hi guys, My code below showing 444 Identical records when it runs. but when you run the produce hql statement below on SQL server its 444 unique records which is the what I am expecting. Did I miss any thing? Mapping: public class AccessibleDocumentsDtoMap : ClassMap<AccessibleDocumentsDto> { public AccessibleDocument...

How do i map this in NHibernate

I Have two classes, Survey and Poll classes. Also I have Question and Question Choice classes. How do I map these so I come out with particular table formats. here is the classes involved. public class Survey { public IList<Question> Questions { get; private set; } } public class Poll { public Question Question { get; set; ...

NHibernate: Map same class to multiple tables depending on parent

I have a model where multiple classes have a list of value types: class Foo { public List<ValType> Vals; } class Bar { public List<ValType> Vals; } Foo and Bar are unrelated apart from that they both contain these vals. The rules for adding, removing, etc. the ValTypes are different for each class. I'd like to keep this design in my c...

What's wrong with this Fluent NHibernate Configuration?

What's wrong with the following setup? The Where filter on the AutoPersistanceModel does not appear to be working and the table name convention does not appear to be working either. The error I'm evenually getting is "The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'property' in namespace 'urn:nhi...

How do I override a convention's cascade rule in fluent nhibernate

I have two classes public class Document { public virtual int Id { get; set; } public virtual IList<File> Files { get; set; } } public class File { public virtual int Id { get; protected set; } public virtual Document Document { get; set; } } with the following convention: public class HasManyConvention : I...