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

NHibernate creates 2 fields in one-to-many relationship

I have the following entities, mapped by code: VarRecipeMapping.cs public VarRecipeMapping() { Table("var_recipe"); // ... Bag(x => x.Entries, m => { m.Cascade(Cascade.All | Cascade.DeleteOrphans); …
kagmole
  • 2,005
  • 2
  • 12
  • 27
0
votes
1 answer

How to make nhibernate not combine results from inherited objects?

I have a problem with nhibernate queries. The result i get back is a mix from two tables. How do i tell nhibernate not to combine the result from the different tables. This is my query: using (var session = SessionFactory.OpenSession()) { using…
0
votes
1 answer

nhibernate mapping by code identity not insert

I'm using nhibernate 5,1,1. Mapping by code when you add an entry, you send 2 requests select max (id) From Bred insert Into Bred (Id, Name, PetType) valuses ({value of max (id)}, text, 1) I need the field id not to be sent in the insert request…
0
votes
1 answer

NHibernate: Mapping protected members in component (composite-element) mapping

I'm building an application which uses NHibernate mapping by code, and I am unable to map protected properties when I use a component mapping (equivalent to hbm composite-element mapping) for a collection of value objects. I am able to map protected…
0
votes
3 answers

Generate sequential Id for primary key column in NHibernate

How can I generate a Sequential guid for a primary key column in NHibernate. I know how to do that auto increment stuff. But I don't know how to create a sequential Guid for primary key. In the database, data type of Id column is uniqueidentifier.…
Sony
  • 7,136
  • 5
  • 45
  • 68
0
votes
1 answer

NHibernate read timestamp column from SQL Server

I'm using NHibernate 4.0.0.4000 (with mapping by code) and SQL Server 2012. I have to access tables which (among others) contain a timestamp (otherwise also known as rowversion) column. Until now I could simply ignore the column by not using it in…
MilConDoin
  • 734
  • 6
  • 24
0
votes
1 answer

NHibernate hierarchyid SQL Server 2014

I am using NHibernate with mapping by code, connected an SQL Server. This server also contains file tables. The customer, for whom I develop, has an SQL Server 2012, which I also had for quite a while. Due to a recent error in the VM running my…
0
votes
1 answer

Nhibernate mapping by code: many to many

I have problems understanding proper mapping (mapping by code) for updating my data. Here it is (simplified for the sake of clarity). [Persons] table is just a dictionary and is immutable. [Objects] can be: created, modified with…
tester.one
  • 369
  • 2
  • 6
  • 23
0
votes
1 answer

displaying parameters used in NHiberate classMapping class

I wrote a little console app that is supposed to write out properties for a given class. It works on "normal" classes, but it just shows a blank list when I try and pass in a NHibernate classMapping class. Stepping through the debugger in Visual…
0
votes
1 answer

NHibernate - Joining by ID property, not object

I have the following tables : Customer(ID, Name) Transaction(ID, CustomerID, Date) The mapping objects for the tables are defined without objects, only primitive types : Customer(int ID, string Name) Transaction(int ID, string CustomerID,…
user779444
  • 1,365
  • 4
  • 21
  • 38
0
votes
1 answer

NHibernate mapping by convention inheritance model mapping

I am trying to map this class structure: public abstract class Entity { public virtual Guid Id {get;set;} public virtual int Version {get;set;} } public class Parent: Entity { public virtual string ParentName {get;set;} ...…
Luka
  • 4,075
  • 3
  • 35
  • 61
0
votes
1 answer

How do I specify a property as required (NOT NULLABLE)?

I am trying my hand at NHibernate's built-in mapping by code. I've got it mostly working now. My problem is how do I configure which properties on my objects are required in the database within the convention? I'm guessing this would be some sort of…
Origin
  • 1,943
  • 13
  • 33
0
votes
1 answer

By code mapping of many-to-many with OrderBy

I'm using by code mappings and trying to map a manytomany. This works fine but I need OrderBy for the child collection items. I noticed this has been omitted (it does exist in the HBM mappings). e.g. public class Mapping :…
0
votes
1 answer

NHibernate mapping-by-code equivalent of for composite Dictionary keys

Is it possible to map a dictionary with a multi-column key using mapping-by-code? I have not yet found an equivalent to yet. Example entities: public class Warehouse { // ctors private IDictionary
chris
  • 2,541
  • 1
  • 23
  • 40
0
votes
1 answer

Mapping list of value objects in nhibernate

I have model House which has list of doors (door represents value object) public class House : Entity { public int Id { get; set; } public List Doors { get; set; } ... public House(){ Doors = new List(); …
user1765862
  • 13,635
  • 28
  • 115
  • 220