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

order columns by name when using SchemaExport

i have a legacy db structure like table t1 ( c0 bigint, // pk c10 bigint, // deleted flag ) table t2 ( c0 bigint, // pk c1 bigint, // fk to t1.c0 c10 bigint, // deleted flag ) and classes class Entity { public virtual long Id {…
2
votes
1 answer

NHibernate mapping by code: How to map IDictionary?

How can I map these Entities using mapping-by-code: public class Foo { public virtual IDictionary Bars { get; set; } } public class Bar { public virtual int Id { get; set; } public virtual string Name { get; set; } } I…
Yogesh
  • 14,498
  • 6
  • 44
  • 69
2
votes
1 answer

one to many mapping in NHibernate 3.2 mapping by code

I'm trying to learn NHibernate 3.2 built-in mapping by code api (NOT Fluent NHibernate). Can you help me to map a one-to-many relationship between these entities please? public class Member { public virtual int Id { get; set; } public…
amiry jd
  • 27,021
  • 30
  • 116
  • 215
2
votes
2 answers

Nhibernate 3.2 start to finish walk-through that uses built in conForm

I'm looking for a tutorial on Nhibernate 3.2 that uses the built-in code configuration that NHibernate provides. I'm not interested in using Fluent NHibernate, nor the old-style XML mappings.
contactmatt
  • 18,116
  • 40
  • 128
  • 186
2
votes
3 answers

How to set default value for table column in nhibernate 3.2 using Mapping By Code?

I was using Fluent NHibernate as mapping mechanism for my NHibernate projects. But when it came to NHibernate 3.2, I realized that it has mapping by code built in, and no Fluent Nhibernate releases will be published for NHibernate 3.2. I encountered…
Liu
  • 645
  • 2
  • 8
  • 16
2
votes
1 answer

NHibernate 3.2 Mapping IDictionary By Code

I'm having a problem mapping to IDictionary using the new Loquacious configuration. Here's the class: public class Person { public Person() { Description = new Dictionary(); } public virtual int Id { get; set;…
2
votes
2 answers

Loquacious many-to-many not updating database when child added

Consider the following models/mappings [DataContract] public class CustomPhrase : ModelBase { private ICollection translations; public CustomPhrase() { this.translations = new List(); } [DataMember] …
2
votes
1 answer

Why NHibernate create a temporary table when I call the Update method on Query?

I just want to update a column table based on a condition. Here my code : this.session.Query() .Where(e => [...]) .Update(c => new { Enabled = true }); This call generates the following SQL : insert into HT_event SELECT…
2
votes
3 answers

C# NHibernate: How to do constructor injection into classmapping derived class?

I am new with NHibernate. I somehow not able to find answer for my issue. So let me ask here. How can I dependency inject something into a class like this: /* public abstract class ByCodeAutoClassMapping<T> : ClassMapping<T> where T :…
Erhan KALUÇ
  • 21
  • 1
  • 2
2
votes
1 answer

NHibernate: c# action on cascade deletion

I've implemented one-to-many code mapping with cascade deletion. I have associated file with child entity. I want to delete file automatically on child cascade deletion. How can it be implemented?
Dem0n13
  • 766
  • 1
  • 13
  • 37
2
votes
2 answers

NHibernate Mapping-by-Code

How to add a additional field in the database schema(SQL) from NHibernate mapping exported that not exist on entity? I have: Property(x => x.Name, "Name"); Property(x => x.Description, "Product"); and I want add to exported…
2
votes
1 answer

Mapping-By-Code ignores Column Name in BagPropertyMapper

I'm encountering a problem, and I think it's an NHibernate defect. My Database Schema, containing a simple Parent-Child mapping: TABLE Company ( ID BIGINT PRIMARY KEY ) TABLE CompanyMailRecipient ( ID BIGINT…
Andrew Shepherd
  • 44,254
  • 30
  • 139
  • 205
2
votes
2 answers

How to map Enum in NHibernate using Mapping by Code

I am getting following exception while accessing data form database using fluent NHibernate An exception of type 'NHibernate.HibernateException' occurred in NHibernate.dll but was not handled in user code Additional information: Can't Parse 1 as…
MANISH KUMAR CHOUDHARY
  • 3,396
  • 3
  • 22
  • 34
2
votes
1 answer

nhibernate : read write list of string

I know I can read write list of string like below using nhibernate HasMany(x => x.Attachments) .KeyColumn("RowId") .Table("PostTable").Element("PostKey"); But this creates an extra table, is there a way e.g. UserType or something else, so…
harishr
  • 17,807
  • 9
  • 78
  • 125
2
votes
1 answer

How would I join a table on a non primary key field using NHibernate Mapping.ByCode?

I have an employee table: Employee { Name EmployeeId -pk PositionId -fk } The positionId maps to the position table: Position { PositionId -pk ReportsToId PositionName PositionDescription } The ReportsToId field is a…
1 2
3
10 11