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
1
vote
1 answer

Bi-directional NHibernate mapping by code

Just to be clear - this question is not about Fluent NHibernate. I have a Parent and Child classes, with a one-to-many relationship between them. The code is shortened for readability. public class Child { int Id; string Name; } public…
1
vote
2 answers

Effective Date in nhibernate

I have a many to many relationship between two existing tables (User: UserId, Name) and (Location: LocationId, Name), these can't be changed. I have used an many-to-many mapping, but we have a new requirement to include history/future movements. I…
1
vote
1 answer

NHibernate mapping by code Map collection

I'm moving from xml mapping to a code based mapping. There is a problem I'm experiencing with NHibernate Map collection. Below is the xml mapping which perfectly works (it is a bit simplified, there is actually more properties and…
Alex M
  • 2,410
  • 1
  • 24
  • 37
1
vote
1 answer

NHibernate mapping by code: Mapping userTypes by convention

I would like to know how to configure NHibernate "mapping by code" so that when I map a property of a certain type, it uses a certain userType to perform that mapping. It figures this out by convention. For example, if I have an Account class with a…
Sir Rippov the Maple
  • 7,491
  • 5
  • 42
  • 52
1
vote
2 answers

database column to constant value without the need for a property in the entity class with mapping by code

this is almost the same as this question except using NH's mapping-by-code. I really need the virtual properties because i also want to use SchemaExport to create the database for different rdbms without the need to create/maintain scripts for…
Firo
  • 30,626
  • 4
  • 55
  • 94
0
votes
1 answer

Mapping IDictionary with MappingByCode

How can I map IDictionary? I've done this way: Map(x => x.BookedResources, c => { c.Key(ck => ck.Column("ProposedAction")); c.Table("BookedResources"); }, k =>…
0
votes
1 answer

Inserting records in postgres using NHibernate 3.2 (loquacious) and bycode mappings

I am working on a very basic NHibernate 3.2 task, inserting records into existing Postgres tables. I am using very simple object so that they make sense for this question. The postgres tables are as follows: CREATE TABLE cat ( id serial NOT…
Lucas
  • 478
  • 4
  • 15
0
votes
1 answer

Mapping in NHibernate 3.2 - Arrays, Custom Lists

Looking at NHibernate 3.2 at the moment and am struggling a little with the mapping by code. Can anyone provide me with a simple example of mapping an array of strings or ints? I can't seem to find any code examples or documentation anywhere that…
David
  • 1,731
  • 24
  • 37
0
votes
1 answer

How to implement Cascading in NHibernate using ClassMap (mapping by code)?

I am having some trouble with what seems to be a relatively simple cascading operation, but which I simply cannot get to work. I have four (simplified) classes: class Class { uint? ID; //IDs are null when they are created, the database…
0
votes
1 answer

How to map an entity as a class property of another entity using mapping by code (NHibernate)

I want my entity's text properties being saved in several languages. For this I just want to store a FK to the TextContent table (which basically contains only a key) and a separate Translation table which contains a row for each translation. Here…
Alexandre A.
  • 1,619
  • 18
  • 29
0
votes
1 answer

Mappings classes into entities using Domain Driven Design with NHibernate as ORM

Hello I want to map class with encapsulated fields. Earlier i used EF Core to map my domain models on entities but this time i want to try something new and i choosed NHibernate as ORM. Below is my domain classes: public class Order { public…
0
votes
1 answer

One-to-one relationship in NHibernate using composite key

I'm trying to figure out the proper way to model a one-to-one (or one-to-zero) relationship in NHibernate, or indeed to learn categorically whether such a thing can be done. Currently I have two models, Document and ScriptDocument whereby there…
Mark Embling
  • 12,605
  • 8
  • 39
  • 53