Questions tagged [fluent-nhibernate-mapping]

Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate

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.

Resources

626 questions
4
votes
1 answer

Problems Fluent Nhibernate Mapping MySQL Time(6) to C# DateTime

i have a MySql table with the following schema Field Type Null Key Default Extra id int(11) NO PRI NULL auto_increment Date date YES MUL NULL Time time(6) NO MUL NULL Exch …
4
votes
1 answer

How to stop NHibernate from adding "this_." to queries without creating dialect

I am using Fluent NHibernate to query my Oracle 11g database. In the fluent mapping files I have a Mapping which looks like that Map(x => x.WaterLevel).Formula("CAST(WATER_LEVEL AS DOUBLE PRECISION )") However, when I run my tests I…
4
votes
3 answers

Fluent NHibernate References with constants

I have a table mapped in Fluent NHibernate. This table must join to another table on an ID, but must also filter the joined values on that table against a set of constant values. Consider the following SQL: SELECT * FROM Table1 INNER JOIN …
4
votes
2 answers

Adding IAutoMappingOverride with interface for all domain classes

I have an IAuditable interface that defines my class domain as auditable. public interface IAuditable { DateTime CreateAt { get; } IUser CreateBy { get; } DateTime? UpdateAt { get; } IUser UpdateBy { get; } } For these classes…
4
votes
0 answers

How to define a nullable foreign key in Fluent NHibernate?

I want to have a foreign key that can be null: a child has zero or one parents. NHibernate always complains about Foreign key reference target does not exist. Is it even impossible to do what I want? Child: References( x => x.Parent…
Dani
  • 2,602
  • 2
  • 23
  • 27
4
votes
1 answer

NHibernate.MappingException: No persister

I've got a problem doing updates with a stateless session and I'm wondering if anyone has seen something like this. (NHibernate 3.1). I'm basically doing the following: SomeEntity e = statelessSession.Get(id); e.SomeProperty = "a new…
4
votes
4 answers

How to serialize / deserialize elements lists using Fluent NHibernate mappings?

I'm trying to use Fluent NHibernate mapping to serialize / deserialize data. Starting from a "root" entity, I use the mapping to build a graph with all the entities linked to that entity. Then I serialize this set of entities. I've got this mapping…
4
votes
3 answers

Defining a Derived Boolean Property using Fluent NHibernate

I have a class public class Account { public DateTime? StartDate {get;set;} public DateTime? EndDate {get;set;} public bool IsActive {get;set;} } the IsActive property is defined as a formula as .Formula(" StartDate < GETDATE() and…
4
votes
2 answers

Fluent NHibernate - Cascade All Delete Orphan not doing anything on delete

I have two simple classes which reference each other as a one-to-many relationship defined below: public class Project { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual IList
4
votes
2 answers

Fluent nhibernate SQL Server 2008 R2 Express very long string saving issue

I have an Article object which has various properties: public class Article { public virtual string Title { get; set; } public virtual string Body { get; set; } } I am using the fluent configuration to load the…
4
votes
1 answer

Fluent nhibernate one-to-many

I have a one-to-many relationship and cannot get cascade to work, once I set cascade I just get "object references an unsaved transient instance ...". My mapping looks like this public class SharedDetailsMapping : ClassMap { …
Christian
  • 908
  • 1
  • 13
  • 22
4
votes
1 answer

Fluent NHibernate's Length property not working on update

I have the next mapping, where I specify the length of some string fields: public ResolutionMap() { Schema("dbo"); Table("Resolution"); Id(x => x.IdResolution, "resolution_id").UnsavedValue(0).GeneratedBy.Identity(); Component(x => x.Store,…
4
votes
1 answer

NHibernate recreates every associated item

I have a very simple object models. public class Contact { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual Device Device { get; set; } public virtual…
Davita
  • 8,928
  • 14
  • 67
  • 119
4
votes
2 answers

Fluent Nhibernate composite key mapping

I have tried to figure out this question for quite a long time. I have a hacky way to make it work. I just want to know if this is possible in Fluent NHibernate mapping. Say I have two tables for example: Table ComissionLevel { Year, …
4
votes
1 answer

Mapping a flat view to class hierarchy in fluent nHibernate

I'm developing an app that has a model using race results / times etc.. I've got a model that looks something like: public class Competitor { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual…
Alex
  • 37,502
  • 51
  • 204
  • 332