fluent-nhibernate

Fluent Nhibernate configuring OptimistickLock.Dirty() with Transaction.IsolationLevel.ReadCommited when the row locked in Oracle 10g

The problem is : I have a working system with FluentNhibernate. I have a legacy database and it's hybrid system which suppose to give an answer to a new and old systems as one. So that means I couldn't use the Version - which means at this point to change the schema and add column to each table. I've added OptimistickLock.Dirty() with ...

Readonly collection properties that NHibernate can work with

Hi all My domain classes have collections that look like this: private List<Foo> _foos = new List<Foo>(); public virtual ReadOnlyCollection<Foo> Foos { get { return _foos.AsReadOnly(); } } This gives me readonly collections that can be modified from within the class (i.e. by using the field _foos). This collection is mapped as follo...

NHibernate error (Cannot insert duplicate key with unique index)

Hello guys... My Class Client : public class Client : Entity { public Client() { ListClientObjectX = new List<ClientObjectX>(); } public virtual IList<ClientObjectX> ListClientObjectX { get; set; } ... } My Class ClientObjectX public class ClientObjectX: Entity { public ClientObjectX() ...

Getting magic strings out of QueryOver (or Fluent NHibernate perhaps)?

One of the many reason to use FluentNHibernate, the new QueryOver API, and the new Linq provider are all because they eliminate "magic string," or strings representing properties or other things that could be represented at compile time. Sadly, I am using the spatial extensions for NHibernate which haven't been upgraded to support Query...

Ignoring properties in Fluent NHibernate with VB.Net (2.0)

Because there is so little information about VB.Net and (Fluent) NHibernate to be found, I decided to write this question to all other developers finding themselves looking for more information. On of the things i had to struggle with was how to Ignore properties in NHibernate. The reason i had to ignore properties was because we used ...

Mapping a collection of entities in fluent nHibernate

I'm developing a question/answer based application I have a Post table in the db along the lines of: ID Title Body DateCreated AuthorID AuthorName (in case user not registered) AutherEmail (as above) PostType (enum - 1 if question, 2 if reply) Show (bit field) Then, there is "PostBase" - which is an abstract class (this has pro...

Fluent NHibernate has many mapping where child table has not primary key

So I'm a couple of weeks into NHibernate so pleae bear with me. I am working on a legacy database with lots of weird issues. I have a name object public class Name { public Name() { Addresses = new List<Address>(); } public virtual string Id { get; set; } public virtual str...

How to enable LazyLoad in Fluent NHibernate?

I'm testing Fluent NHibernate with NorthWind database. Now, I've created Employee and EmployeeMap class. Source code is like below. class Employee public class Employee { public virtual int EmployeeID { get; private set; } public virtual string LastName { get; set; } public virtual string FirstName { get; set; } public ...

Testing multiple db mappings in MappingIntegrationTests

What's the best approach for testing multiple db's in a s#arparch project? The current SetUp() code in MappingIntegrationTests tries to test each assembly against the first database. string[] mappingAssemblies = RepositoryTestsHelper.GetMappingAssemblies(); configuration = NHibernateSession.Init(new SimpleSessionStorage(), mappingAss...

Consuming Fluent Nhibernate Mappings

I'm a big believer in DRY so after setting up ClassMap objects in fluent nhibernate, how can I consume these mappings in code not using Nhibernate? Edit: Example, I have a class that is mapped but also uses a stored procedure to populate itself and it's children (and their children) in a single database call. When populating objects fro...

Why is ModelState.IsValid always false? FNH Model is expecting Id field

I am rather stumped on this. Fluent Nhibernate v1.1.0.685 NHibernate v2.1.2.4000 When I check the ModelState.IsValid prop before calling the Save() on the Repository. The IsValid prop is always False. When debugging the Id value is "" (empty) in the Model. I have overridden the Mappings for the Id :: mapping.Id(x => x.Id).GeneratedBy.I...

Mapping single-table-hierarchy with self-referencing properties using Fluent NHibernate

Hello, I'm new to fluent nHiberbate and wanting to put into use in one of my projects. And I'm currently having trouble mapping a class that has both inheritance and self-referencing properties. Here's my scenario: I have an abstract class called Applicant public abstract class Applicant: IApplicant { public virtual long Id {...

Fluent NHibernate or NHibernate for Linq?

Fluent NHibernate or NHibernate, Which one should we prefer for linq support? ...

Fluent NHibernate: Custom condition (WHERE clause) on get, update and delete

I have a table that contains information from many customers ID | employeename | customerId ------------------------------ 1 | employee1 | 188 2 | employee2 | 188 3 | employee3 | 177 Now I would like to get only those employees, whose customerId is 188. How do I map this with Fluent NHibernate so, that on update and del...

S#arp-architecture, NHibernate multiple databases with typed id

I have multiple databases in my SharpArchitecture project and followed the guide outlined here: http://wiki.sharparchitecture.net/FAQ.ashx Everything works fine, except for my entities with assigned ids. I get a "database already configured" when trying to startup the application. Through some digging I get: "Identity type must be int...

DetachedCriteria with 3 OR conditions

How can I achieve this query using DetachedCriteria: Select * from MyTable Where (conditionA = true) or (conditionB = true) or (conditionC = true) or (conditionD = true) ...

Why does AutoMappings add an underscore to Id?

Hi using fluentnibernate automappings to map this public virtual int Id { get; set; } /*...snip..*/ public virtual MapMarkerIcon MapMarkerIcon { get; set; } } to this CREATE TABLE [Attraction]( [Id] [int] IDENTITY(1,1) NOT NULL, [MapMarkerIconId] [int] NULL ) with this: var cfg = Fluently.Configure() ...

fluent nhibernate convention : setting polymorphism mode

Is it possible to create a simple convention to modify the polymorphism mode of a class, if there is a joined-subclass ? Doing this : public class EntityMap : ClassMap<EntityBase> { public EntityMap() { Polymorphism.Explicit(); } } but inside a convention. Using IClassConvention doesn't work, as the Polymorphism p...

How to create a test for Fluent nHibernate conventions?

I am creating a set of conventions for Fluent nHibernate. I create a few conventions, like primary key, foreign key and many-to-many table. I would like to be able to test out these conventions with an in memory database to see if I coded these conventions correctly. Currently, I am setting up nHibernate using an SQlite in-memory datab...

Fluent-Nhibernate Many-To-Many relationshiop issue

I am facing an issue while trying to delete a many-to-many relationship using Fluent Nhibernate. I have following domain classes: public class Organisation { public virtual int Id {get; set;} private IList<OrganisationRelationshiop> relatedOrganisations; public virtual IList<OrganisationRelationship> RelatedOrganisation ...