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
88
votes
7 answers

How do you map an enum as an int value with fluent NHibernate?

Question says it all really, the default is for it to map as a string but I need it to map as an int. I'm currently using PersistenceModel for setting my conventions if that makes any difference. Update Found that getting onto the latest version of…
Garry Shutler
  • 32,260
  • 12
  • 84
  • 119
87
votes
2 answers

Unable to cast object of type NHibernate.Collection.Generic.PersistentGenericBag to List

I have a class called ReportRequest as: public class ReportRequest { Int32 templateId; List entityIds; public virtual Int32? Id { get; set; } public virtual Int32 TemplateId { get { return…
inutan
  • 10,558
  • 27
  • 84
  • 126
62
votes
4 answers

How can I have NHibernate only generate the SQL without executing it?

I know how to log the SQL to log4net/NLog/trace window at runtime with the show_sql configuration option. What I'm looking for is a way to give a Query() to NHibernate retrieve the generated SQL. I've looked through the Persister class, the…
hometoast
  • 11,522
  • 5
  • 41
  • 58
54
votes
1 answer

How to update database table schemas with NHibernate schema generation?

I'm trying to figure out how to use NHibernate configuration with mapping to update table schemas, rather than dropping and recreating them. Currently I'm using the NHibernate.Tool.hbm2ddl.SchemaExport obj with FluentNHibernate to generate the…
Mark Rogers
  • 96,497
  • 18
  • 85
  • 138
52
votes
3 answers

How to configure Fluent NHibernate to output queries to Trace or Debug instead of Console?

How to configure Fluent NHibernate to output queries to Trace or Debug instead of Console? I'm using MsSqlConfiguration.MsSql2008.ShowSql() but it has no parameters and I can't find anything on Google.
Andre Pena
  • 56,650
  • 48
  • 196
  • 243
44
votes
1 answer

Fluent NHibernate: How to create one-to-many bidirectional mapping?

Basic question: How to I create a bidirectional one-to-many map in Fluent NHibernate? Details: I have a parent object with many children. In my case, it is meaningless for the child to not have a parent, so in the database, I would like the foreign…
Nathan
  • 10,593
  • 10
  • 63
  • 87
41
votes
4 answers

Mapping Composite keys in Fluent NHibernate

I am new to Fluent NHibernate and have been unable to figure out how to map composite keys. How can I do this? What approach do I need to take?
pang
  • 3,964
  • 8
  • 36
  • 42
41
votes
5 answers

The length of the string value exceeds the length configured in the mapping/parameter

I am trying to insert some very long text into a string prop - it worked perfectly fine with LinqToSql, now I have switched over to NHibernate and want to save the same entity, but nHibernate throws the above exception. How can I fix…
Haroon
  • 3,402
  • 6
  • 43
  • 74
40
votes
6 answers

Override for fluent NHibernate for long text strings nvarchar(MAX) not nvarchar(255)

When ever you set a string value in fluent NHibernate it alwasy sets the DB vales to Nvarchar(255), I need to store quite a lot of long string which are based on user inputs and 255 is impractical. Just to add this is an issue with the automapper…
TheAlbear
  • 5,507
  • 8
  • 51
  • 84
39
votes
2 answers

Fluent NHibernate - Create database schema only if not existing

I have an application where I use Fluent Nhibernate to create my database. This far I've been recreating the database schema each time. The code that does this is this: public NhibernateSessionFactory(IPersistenceConfigurer config) { …
stiank81
  • 25,418
  • 43
  • 131
  • 202
39
votes
1 answer

What are the differences between HasOne and References in nhibernate?

What are the differences between HasOne() and References() in nhibernate?
Hannoun Yassir
  • 20,583
  • 23
  • 77
  • 112
36
votes
5 answers

NHibernate or Fluent NHibernate?

I would be interested in hearing op opinions from others regarding whether which they would choose (no 'neithers' please ;), and why. What are the downsides to using fluent? (version dependancy maybe?) Pros, Cons, Experiences etc.
UpTheCreek
  • 31,444
  • 34
  • 152
  • 221
35
votes
9 answers

Where can i find a Fluent NHibernate Tutorial?

I have googled and looked around does anyone know of any hidden gems out there that is not in first couple pages of a google search....
Shane Scott
  • 1,583
  • 2
  • 13
  • 11
34
votes
3 answers

How to specify table name in Fluent NHibernate ClassMap class?

I am newbie to NHibernate and trying to use Fluent for mapping. My entity class name is different from the database table name it has to be mapped to. I am using mapping class derived from ClassMap<>, but I can't specify the table name: the property…
twk
  • 3,122
  • 2
  • 26
  • 36
34
votes
2 answers

How to configure fluent nHibernate with MySQL

I'm trying to configure nHibernate to use a MySql database. I found examples for mssql and sqlite but none for mysql. So, how do I change this so it uses mysql: Fluently.Configure().Database( MsSqlConfiguration.MsSql2005.ConnectionString( …
Spikolynn
  • 4,067
  • 2
  • 37
  • 44
1
2 3
99 100