fluent-nhibernate

Nhibernate -- Excuting some simple HQL

Hi all, I have map the entities in .hmb.xml and define attribute for all entity in classes. I have some basic accomplishment and get all the record using below code. public List<DevelopmentStep> getDevelopmentSteps() { List<DevelopmentStep> developmentStep; developmentStep = Repository.FindAll<DevelopmentStep>(new Orde...

Fluent NHibernate + multiple databases

My project needs to handle three databases, that means three session factories. The thing is if i do something like this with fluent nhibernate: .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly())) the factories would pick up all the mappings, even the ones that correspond to another database I've seen th...

How can I map one to one relationship in Fluent NHibernate. I have tried everything else

I have this table structure and would like to map it using Fluent Hibernate (subclass if possible). I cannot change the structure because the database has too many records and might cause major applications rework. It would be easier if the Id from Party table was a foreign key in person and organization table, but in the particular scen...

MVC + Nhibernate + Oracle Schema Configuration

Our customer wants us to use a connectionstring with username = "external" and add schemaName "original" infront of our queries like: "select columnA from original.TableA" I dont want to change mapping files which are shared by other projects, tried adding default schema as: <property name="default_schema">original</property> But t...

How do I set the default transaction isolation level in Fluent NHibernate?

I would like to set the default transaction level to ReadCommitted in my Fluent NHibernate configuration. If I were using XML mapping files, I could add a key to my config file: <add key="hibernate.connection.isolation" value="ReadCommitted" /> but I can't figure out how to accomplish this with Fluent configuration. ...

Fluent NHibernate - Map only a few classes in assembly

Hi, I have a entity project which holds about 30 classes and this project is used in several web applications. One application maybe uses all the 30 classes but another one only uses 3 classes. So my question is: How can I add just the classes that a uniqe application needs? My first thought was to add the names of the needed classes i...

Fluent NHibernate View Mapping requires Id Column

Hi Trying to use FNH to map a view - FNH insists on having a Id property mapped. However not all of my views have a unique identifing column. I can get around this with XML mappings as I can just specify a <id type="int"> <generator class="increment"/> </id> at the top of the mapping. Is there any way to duplicate this i...

Fluent NHibernate: mapping complex many-to-many (with additional columns) and setting fetch

I need a Fluent NHibernate mapping that will fulfill the following (if nothing else, I'll also take the appropriate NHibernate XML mapping and reverse engineer it). DETAILS I have a many-to-many relationship between two entities: Parent and Child. That is accomplished by an additional table to store the identities of the Parent and C...

Nhibernate - Getting Exception executing SQL Query

Hi, I am excuting SQL Query using Nhibernate, here is my code public ArrayList getDocumentsForApproval(string ReleaseId) { string query = string.Format("SELECT distinct doc.Id, doc.Name as Doc, doc.url as url, suser.Name as Author, ds.name, CONVERT(VARCHAR(11), doc.DateEntered, 101) as DateEntered FROM dbo.Documents doc INN...

Fluent NHibernate - Set reference key columns to null

Hi, I have a table of Appointments and a table of AppointmentOutcomes. On my Appointments table I have an OutcomeID field which has a foreign key to AppointmentOutcomes. My Fluent NHibernate mappings look as follows; Table("Appointments"); Not.LazyLoad(); Id(c => c.ID).GeneratedBy.Assigned(); Map(c => ...

How can I ignore properties of a component using Fluent Nhibernate's AutoPersistenceModel?

I am using Fluent NHibernate AutoMappings to map my entities, including a few component objects. One of the component objects includes a property like the following: public string Value { set _value = value; } This causes an NHibernate.PropertyNotFoundException: "Could not find a getter for property 'Value'..." I want to ignore ...

NullReferenceException mapping collection of enum with Fluent NHibernate automapping

I have a class that contains a collection of enumeration as follows. public enum TransactionType { ... } public class PaymentMethod { ... public virtual IList<TransactionType> SupportedTransactionTypes { get; set; } } Other references to the TransactionType enumeration are working correctly but with this collection I get an exc...

First Fluent NHibernate Project

I'm trying to follow the "Your first project" tutorial at http://wiki.fluentnhibernate.org/Getting_started and have hit a roadblock. When I try to run the console application, I'm getting this error: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for...

Fluent NHibernate - How to map a non nullable foreign key that exists in two joined tables

I'm mapping a set of membership classes for my application using Fluent NHibernate. I'm mapping the classes to the asp.net membership database structure. The database schema relevant to the problem looks like this: ASPNET_USERS UserId PK ApplicationId FK NOT NULL other user columns ... ASPNET_MEMBERSHIP UserId PK,FK App...

Calling Stored procedure using Nhibernate -- Getting exception No persister for:

here is code, how I am calling Stored procedure ISession session = NHibernateHelper.GetCurrentSession(); IQuery q = session.GetNamedQuery("ps_getProgressBarData1"); var t = q.List(); XML mapping <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="ReleaseDAL" assembly="ReleaseDAL"> <sql-query name="ps...

Getting Started with Fluent NHibernate

I'm trying to get into using Fluent NHibernate, and I have a couple questions. I'm finding the documentation to be lacking. I understand that Fluent NHibernate / NHibernate allows you to auto-generate a database schema. Do people usually only do this for Test/Dev databases? Or is that OK to do for a production database? If it's ok ...

How to determine one to many column name from entity type

I need a way to determine the name of the column used by NHibernate to join one-to-many collections from the collected entity's type. I need to be able to determine this at runtime. Here is an example: I have some entities: namespace Entities { public class Stable { public virtual int Id {get; set;} public virtual ...

Mapping multiple foreign keys to one table

Hi I'm using Fluent Nhibernate, i need to create mappings for 2 tables: Simplified, they look like this: TAXI ( Id int primary key Name varchar ) ORDER ( Id int primary key RedirectedFrom int foreign key on TAXI.Id RedirectedTo int foreign key on TAXI.Id ) So, two foreign keys from table TAXI refer to table ORDER Q: Is tha...

Call Stored Procedure in Nhibernate - exception - No persister for

I am getting exception when calling Stored Procedure using Nhibernate and here is the exception No persister for: ReleaseDAL.ProgressBars, ReleaseDAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null here is class file public class ProgressBars { public ProgressBars() { } private Int32 _Tot; private Int32 _subto...

Restricting deletion with NHibernate

I'm using NHibernate (fluent) to access an old third-party database with a bunch of tables, that are not related in any explicit way. That is a child tables does have parentID columns which contains the primary key of the parent table, but there are no foreign key relations ensuring these relations. Ideally I would like to add some forei...