fluent-nhibernate

mapping collection type with Fluent NHibernate

Hello guys. I've used Fluent NH in my project but I'm having some problems with using the Collection class. Here's the code for my classes public class Vendor { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual Services Services { get; set; } } public class Services : I...

need help to convert this mapping file from NHibernate to Fluent NHibernate

i want to convert this mapping file from NHibernate to Fluent NHibernate <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="CustomCollectionsBasic.Core.Category, CustomCollectionsBasic.Core" table="Categories"> <id name="ID" column="CategoryID" unsaved-value="0"> <generator class="identity" /...

Castle Windsor & NHibernate facility: Value cannot be null. Parameter name: classType

Hi I am attempting to use Castle windsor Nhibernate Facility with fluent Nhibernate and Im getting the error above, as far as Im aware , I have followed the instructions on setting this up. Has anyone else seen this issue and maybe offer some advice? Thanks Value cannot be null. Parameter name: classType Description: An unhandled except...

Castle windsor Nhibernate Facility cCastle.Facilities.NHibernateIntegration.ISessionManager which was not registered.

Hi Iam having some trouble getting castle Nhibernate facility up and running properly. This error I guess makes sense because the Nhbernate repository constructor takes in an ISessionManager as a constructor argument, my question is does castle not inject this dependency? or is there something wrong with my configuration UserServiceTest...

FluentNHibernate.MissingConstructorException when building the SessionFactory

I'm trying to fluently configure a SessionFactory to access an Oracle9i database, using ODP.Net, and I'm getting this MissingConstructorException. I've got the actual fluent mappings sorted out ok, but I'm not sure what else it is that I've done wrong. Here is the exception: BasicConnectionTests.AssertThatWeCanConnectToADatabase : F...

NHibernate.QueryException: could not resolve property

Hello all, I'm using FluentNHibernate and Linq To Nhibernate, with these entities (only the relevant parts): public class Player : BaseEntity<Player> { private readonly IList<PlayerInTeam> allTeams = new List<PlayerInTeam>(); public IEnumerable<Team> Teams { get { return from playerInTeam in all...

Nhibernate cache problem while using SQL Server triggers

Hey! I am using Nhibernate with Fluent, to persist a SQL Server 2008 express database in a business application. I have a class named Receipt which contains a list with many objects named ReceiptItems. The user can create a receipt, add Receiptitems to it, and edit it as long as its not marked Finished. This part works well and saves t...

Update parent table from child in Asp.net and fluent nhibernate

Hi, I'm trying to update the data in the parent table that is referenced in the child table from the child's view in Asp.net. I mapped the tables using Fluent Nhibernate. In the child table, the mapping looks like this: public class ChildMap: ClassMap<Child> { public ChildMap() { Id(i => i.childID).Not.Nullable(); ...

NHibernate asks .NET to convert a string parameter to an integer, don't know why

(Edited to avoid leading down the wrong road) Before giving details, very short version: I have a SQL statement I need to get out of NHibernate, and I have Criteria API statements that give it to me. The NHibernate is trying to do something wrong with the statement it generates, and I'm trying to figure out why. I have the following m...

Automapping collection convention

ok, I have difficult time with automapping collections using fluent nhibernate. This time I tried to apply a collection convention which simply says to use camelCaseField with underscore. Well I got the convention loaded and I hit the breakpoint in the method below FNH still produces strange mapping. What I am doing wrong? public class ...

Using custom C# attributes to select Fluent conventions

Suppose you have sets of Fluent conventions that apply to specific groups of mappings, but not to all of them. My thought here was, I'll create custom C# attributes that I can apply to the Fluent *Map classes - and write conventions that determine acceptance by inspecting the *Map class to see if the custom attribute was applied. That ...

Fluent NHibernate Mapping Exception On Compiling Mapping Document

I have an NHibernate configuration file as follows: <?xml version="1.0" encoding="utf-8" ?> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > <session-factory name="MyProject"> <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> <property name="connection.provider">NHibernate.Connection.D...

Fluent Nhibernate - Schema Mapping Question

If in my classmap I have SchemaAction.None(); and if I also have .ExposeConfiguration(cfg => { new SchemaExport(cfg) .Create(false, false); }) Can I ensure that nhib will not touch the db schema in any fashion. In other words the only write action will be that of entitie...

How do I use Fluent Nhibernate many-to-many for optimal performance?

I have a product table that has a many-to-many relation to itself (using a two-column many-to-many table) and I have set it up in Fluent NHibernate with the following code: public class ProductConfiguration : ClassMap<Product> { public ProductConfiguration() { Table("Product"); Id(p => p.Id).GeneratedBy.Guid(); ...

NHibernate - How to fetch conditional data from database using hbm file mapping

Hello, Currently I am using many-to-one element in hbm file to fetch the data object from database like following.... <property name="ContactId" length="4" /> <many-to-one name="DefaultContact" column="ContactId" class="Models.Contact" update="false" insert="false"/> This code is fetching the data properly, but no...

Automatically update both end of a one to many relationship with NHibernate

Hello, It is of a newby question, so sorry in advance. I'm using fluent NHibernate and get a strange behavior on it. I have two classes that look like that (simplified) : public class Group { public virtual int Id{get;protected set;} public virtual String Name{get;set;} public virtual List<Person> Persons {get; protected ...

fluent nhibernate - how to get mappings from mapping classes

Given the following class: class XMap : ClassMap<X> { HasMany(x => x.ListOfY); HasManyToMany(x => x.ListOfZ); } I need a way to read these mappings. Is there a way to detect these? I need something like: XMap map = new XMap(); var t = GetMappingType(map, "ListOfY"); // somehow returns many-to-one var t = GetMappingType(map, "...

Fluent NHibernate one-to-many Cascade.SaveUpdate() blocks updates to entity

We have an Enrollment object that has a Student object and the Student object has many Enrollment objects. If I leave off the Cascade.SaveUpdate() from the Enrollment's Student reference, updates to the Student table do not execute, but updates to the Enrollment object succeed. But if I add the Cascade.SaveUpdate() on the Enrollment's ...

How do I debug slow NHibernate Select query?

I'm doing a simple query on the database, a search on two columns. I have an index on the columns. When I do the search in SQL Server Management Studio, it takes only a few milliseconds to complete (always less than 10). When I do the same query in NHibernate, it takes over 30 seconds. I've profiled the query, and the generated SQL is fi...

How to use Fluent NHibernate in N-Tier application?

I'm trying to adopt Fluent NHibernate with my project, currently I can get data from database, when I'm at application server, data is include its PK but when I return this data (as List) to client all of its PK is loose. How can I fixed this problem? Update My POCO class is below: PKs are CountryCd and CityCd public class coCity { ...