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
0
votes
1 answer

Fluent Nhibernate Mapping Relationships Across Schemas

I have an object Site, like this public class Site { public virtual int SiteId { get; set; } public virtual Options Options { get; set; } } And I have an options object public class Options { public virtual int OptionsId { get; set;…
Josh
  • 16,286
  • 25
  • 113
  • 158
0
votes
1 answer

Multiple hasmany same keycolumn - illegal access to loading collection

it works. pull the data, but gives this error: illegal access to loading collection public class Image : File { public virtual string ImagePath { get; set; } } public class Video : File { public virtual string…
0
votes
1 answer

Mapping a referenced base class with fluent nhibernate

I am trying to map a class hierarchy which looks like this: public abstract class A { } public class B : A { } public class C : A { } I don't want to map class A because it is abstract, I know I can do: .IgnoreBase() to not map A and map all…
0
votes
1 answer

Retrieve property name from Fluently mapped column name

Background I have a class called 'Dog', which references another class called 'Tail', which has a property called 'Size'. So, if i wanted to know the dog's tail size, it would be 'Dog.Tail.Size'. Perfect. I have this mapped with FluentNHibernate…
0
votes
1 answer

joining 2 table with queryover

I have 3 table in a sample. i am going to join 2 table but i have problem the following is my code :
0
votes
2 answers

"PropertyAccessException: Invalid Cast" when trying to retrieve an enum property stored as an AnsiString

I need to store my enums in the database as varchar instead of nvarchar, so I am using the "AnsiString" mapping as follows: public class Document { public virtual int Id { get; set; } public virtual string Content { get; set; } public…
0
votes
1 answer

My custom ForeignKeyConvention is resulting in two foreign keys being created instead of one

I am trying to create my own foreign key convention that will name the FK in "FK_SourceTable_TargetTable" format. However, when I run it I end up with two foreign keys instead of one. My custom foreign key convention looks like this: public class…
0
votes
1 answer

FluentNHibernate exception when there are slash in the default value

I have been trying to map a string value using FulentNHibernate like below. Map(x => x.FilePath).Length(500).Not.Nullable().Default(@"C:\Program Files\server\data\conf\groups.txt"); But this gives an error. If I add text without slashes it works.…
Kavin404
  • 959
  • 2
  • 11
  • 18
0
votes
1 answer

Fluent NHibernate mapping

I've inserted value into Make and Models table. But the Ids in both tables are showing in Even and Odd number. The Id column suppose to .GeneratedBy.Identity(); as (1,2,3,4.......) in both the parent and child tables Id column. MAKE ID |…
0
votes
1 answer

Fluent NHibernate how to override mappings for an abstract base class

I want to do this for all my Types Of AuditedEntity, but as we've told FH to ignore base abstracts, the code isnt getting hit. i dont want to do this for all my entities and then have someone forget when they add a new typeof public…
jenson-button-event
  • 18,101
  • 11
  • 89
  • 155
0
votes
1 answer

FluentNHibernate.Cfg.FluentConfigurationException NHiberNate

I get an error like this when writing unit test My product class is like this. I added virtual. My map is like this. SqlServerHelper like this. I am using vs code 2022. I'm developing with Net 6.0 entity framework. I am getting this error while…
0
votes
1 answer

Override FluentNHibernate Auto mapping

I need change for the next class data type assumed by default FluentNHibernate Automapping public class plaparte { public virtual int id { get; private set; } public virtual int vivos { get; set; } public virtual int lesionados { get; set; } public…
Guillermo
  • 213
  • 3
  • 15
0
votes
1 answer

FluentNhibernate Mapping

This is my entity-relationship diagram http://s3.subirimagenes.com:81/privadas/1605595base.png Scenario :These are my classes simplified public class plaserv { public plaserv() { plamoviles = new List(); asistencia = new…
Guillermo
  • 213
  • 3
  • 15
0
votes
0 answers

Calling stored procedure on Inherited class in [Fluent] NHibernate without discriminators

I have a working Fluent project with some inherited tables class Base { int BaseId } class Derived : Base {} class Derived2 : Base {} class BaseMap : ClassMap { ID BaseId ); } class DerivedMap : SubclassMap { Id( BaseId ); } class…