Questions tagged [fluent-nhibernate]

Fluent NHibernate lets you write NHibernate mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.

Fluent NHibernate offers an alternative to NHibernate's standard XML mapping files. Rather than writing XML documents (.hbm.xml files), Fluent NHibernate lets you write mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.

Installation Fluent NHibernate can most easily be installed through its NuGet package.

Install-Package FluentNHibernate

Resources

5486 questions
9
votes
4 answers

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…
Pablote
  • 4,745
  • 9
  • 39
  • 46
9
votes
1 answer

How to map count of collection to entity with fluent-nhibernate

With employees and subordinates - I want to load an employee with the count of subordinates in one query. public class Employee { public Name {get;set;} public int NumberOfSubordinates {get;set;} } Resulting SQL should look like : select…
W3Max
  • 3,328
  • 5
  • 35
  • 61
9
votes
3 answers

Using Time columns with NHibernate, Fluent NHibernate and SQL Server 2008

I have a table with a time column in my SQL Server 2008 database. The property of the object I'm trying to map to is a TimeSpan. How can i tell FluentNHibernate to use the TimeAsTimeSpan NHibernate type, so that I don't have cast problems?
9
votes
1 answer

configure Fluent NHibernate mapping to allow INSERT only?

I'm moving a project from SubSonic to NHibernate and am using Fluent NHibernate to perform all of our mapping. Our db schema is pretty straight forward and most of our cases appear thus far to be well illustrated by different blog posts and sample…
bakasan
  • 2,262
  • 2
  • 26
  • 33
9
votes
3 answers

Can I make a Fluent NHibernate foreign key convention which includes parent key name?

I have a database schema where the convention for a foreign key's name is: ForeignTable.Name + ForeignTable.PrimaryKeyName So, for a Child table referencing a Parent table with a primary key column named Key, the foreign key will look like…
Paul Turner
  • 38,949
  • 15
  • 102
  • 166
9
votes
2 answers

Fluent NHibernate Self Referencing Many To Many

I have an entity called Books that can have a list of more books called RelatedBooks. The abbreviated Book entity looks something likes this: public class Book { public virtual long Id { get; private set; } public virtual IList
Jeremy
  • 93
  • 1
  • 5
9
votes
1 answer

NHibernate Could not resolve property

I am getting exception NHibernate.QueryException : could not resolve property: InsuredId. I am new to NHibernate and I could not figure it out. Defining Properties public virtual int InsuredId { get; set; } public virtual string Gender { get; set;…
JuniorDev
  • 193
  • 1
  • 2
  • 13
9
votes
1 answer

FluentNHibernate: What is the effect of AsSet()?

In Fluent Nhibernate what is the effect of specifying AsSet() on a HasMany or HasManyToMany relationship? Assuming the type of the mapped property is an Iesi Set, is there any difference between: HasMany(x => x.MySetProperty) …
cbp
  • 25,252
  • 29
  • 125
  • 205
9
votes
2 answers

Fluent NHibernate, varbinary(max) and SQLite

I have a varbinary field in my sql server database that needs to be varbinary(max). I create my database with NHibernate and I use Fluent Nhibernate for my mappings. I also use SQLite for my unit tests, I use the same mappings I just change the…
Charles Ouellet
  • 6,338
  • 3
  • 41
  • 57
9
votes
4 answers

Validate Bool using Fluent Validator

I want to validate a bool property using fluent validator. Which method should I use? .NotNull() and .NotEmpty() functions didn't work. Thanks.
Leonardo Arruda
  • 241
  • 1
  • 6
  • 14
9
votes
1 answer

How to map a class as immutable using FluentNHibernate?

How can I map a class as immutable using FluentNHibernate. Using hbm I can do like this.
Amitabh
  • 59,111
  • 42
  • 110
  • 159
9
votes
5 answers

Fluent NHibernate mapping

I'm new to NHibernate and Fluent NHibernate. Assuming I have a situation like the following Table Activities (uniquidentier ID, varchar ActivityName) Table ActivityParameters(uniqueidentifier ID, varchar ParameterName, varbinary(8000)…
DaeMoohn
  • 1,087
  • 13
  • 27
9
votes
1 answer

Nhibernate Throws Found shared references to a collection

I have read thru a number of other questions similar to this one - but being new to Nhibernate, none of them seem to answer my question of why is Inhibernate throwing a "Found shared references to a collection: Order.ShippingAddress.Items" to the…
user1069733
  • 485
  • 9
  • 17
9
votes
0 answers

NHibernate casts to decimal when doing AVG

I use nhibernate 3 with fluent mapping and MySQL5Dialect. I do grouping and trying to get average value: var group = new TotalStatistic(); SelectList(s => s .SelectGroup(t => t.RegistryName).WithAlias(() => group.Name) …
pavel
  • 141
  • 6
9
votes
1 answer

Fluent NHibernate -- Saving Entity with Composite Key

First, I have the following table: CREATE TABLE CustomerHub ( CustomerId INT NOT NULL, HubId INT NOT NULL ) Which I have mapped to the this entity: public class CustomerHub { public int CustomerId {get;set;} public int HubId {get;set} …
jckeyes
  • 620
  • 1
  • 7
  • 20