Questions tagged [nhibernate-mapping-by-code]

Mapping-by-code is NHibernate's own API by which mappings can be configured by code. Introduced in NHibernate version 3.2.

Mapping-by-code is NHibernate's own API by which mappings can be configured by code. It was introduced in NHibernate version 3.2. In a strict sense this applies to the namespace NHibernate.Mapping.ByCode. It may als pertain to NHibernate.Cfg.Loquacious, but not FluentNhibernate, which has its own tag.

158 questions
26
votes
2 answers

Getting started with NHibernate 3.2 Loquacious API

I'm starting a new project and I want to use NHibernate 3.2. I know that it can now do something similar to FluentNHibernate and I want to give it a try. But I am having a hard time finding documentation on the Loquacious API. I've seen blog posts…
Pierre-Alain Vigeant
  • 22,635
  • 8
  • 65
  • 101
18
votes
3 answers

Generating Wrong Columns on Queries

We are having an intermittent problem with NHibernate where it will occasionally generate a query with a wrong column on the SQL. If we restart the application the problem ceases to happen (sometimes it requires more than one restart). When the…
Gus Politano
  • 211
  • 1
  • 8
11
votes
2 answers

NHibernate 3.2 many to many mapping by code

I'm trying to learn NHibernate 3.2 built-in mapping by code api (NOT FluentNHibernate, nor xml). Can you help me to map a many-to-many relationship between these entities please? public class Post { public virtual Id { get; set; } public…
8
votes
1 answer

Using a Property mapping with a Formula in NHIbernate

I am trying to map a property to an arbitrary column of another table. The docs say that the formula can be arbitrary SQL and the examples I see show similar. However, the SQL NHibernate generates is not even valid. The entire SQL statement from…
Brian
  • 6,910
  • 8
  • 44
  • 82
7
votes
3 answers

FluentNHibernate or port to NHibernate mapping by code

I have several projects using NH and FNH to generate the mappings (some Fluent some Automapped). There are still some bugs and missing features i need, but it seems that FNH could die because of mapping-by-code integrated into NHibernate. Question:…
6
votes
1 answer

NHibernate - Force escaping on Table Names

Are there any good examples of how to use this (NHibernate.Criterion.IdentifierEqExpression) online? I couldn't find any. I'm a little confused about what you are supposed to pass into the constructor. I pass in an int32 of 1 and I keep thinking my…
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
6
votes
2 answers

Nhibernate One-To-One mapping by code

I am trying to figure out a way to map one to one relationship in nhibernate when referencing column is not a primary key column on second table. For example consider Person Table PersonId (pk) Name and Passport Table PassportId (pk) …
5
votes
1 answer

How to write mappings for a stored procedure

There is an excellent post on how to map return values for a stored procedure call here: http://elegantcode.com/2008/11/23/populating-entities-from-stored-procedures-with-nhibernate/ The mapping in this example has been done through hbm files. I am…
5
votes
2 answers

nHibernate 3.2 database config in code?

NHibernate seems to have some new ways to map entities in code, which is really nice, but I can't find any information about configuring the database connections in code. It has been a while since I used NHibernate (version 2) and I am used to…
A.R.
  • 15,405
  • 19
  • 77
  • 123
5
votes
3 answers

Using NHibernate mapping by code: Cannot insert explicit value for identity column in table 'DietUser' when IDENTITY_INSERT is set to OFF

Took me a while to find an answer for this so thought I'd share the love. When using NHibernate's new mapping by code with SQL Server I'm unable to save an entity. When saving an entity a System.Data.SqlClient.SqlException is thrown with the…
5
votes
2 answers

NHibernate with mapping by code and a SQLite database: saving many-to-one parent-child entities, child gets a null foreign key

Variations of this question have been asked and answered many times and the answers have a lot of overlapping details. I have tried so many different things suggested by these answers, but none of them have worked in my case. I have a SQLite…
rory.ap
  • 34,009
  • 10
  • 83
  • 174
5
votes
1 answer

json.net ignore nhibernate proxy objects during serialization

I am able to serialize proxy objects using below code: public class NHibernateContractResolver : DefaultContractResolver { protected override JsonContract CreateContract(Type objectType) { if…
user2165424
5
votes
3 answers

How to map ntext using NHibernate Mapping-By-Code feature of NHibernate 3.2?

I need to map ntext column of a table using the mapping by code feature in NHibernate 3.2, so that it doesn't get truncated to 4000 characters. What do I neet to change in the following example? "Notes" is the property which has ntext type in sql…
5
votes
2 answers

NHibernate -Temporarily turn off identity

I'm running an NHIbernate solution using SQL CE. I am mapping one the fields in a table as below. However, in order to run some data imports I need to be able to temporarily turn off identity so I can import the data with its existing keys, then…
4
votes
1 answer

Table Per Subclass Inheritance mapping by NHibernate Mapping-by-Code

How to write mappings in new NHibernate Mapping-By-Code in Table Per Subclass strategy for this classes: public class Person { public virtual int Id { get; set; } public virtual string Name { get; set; } } public class JuridicalPerson :…
1
2 3
10 11