nhibernate-mapping

NHibernate Mapping a Many to Many with Data on Join Table

佐手、 提交于 2019-12-23 03:29:13
问题 I have a User table and an Address table. They are connected by a join table. The mapping for that is straight forward, but I have some data on the join table that I would like to show up on the Address table. There may be a better way to set this up also, which I'm open to suggestions for. Here is the table structure. CREATE TABLE [dbo].[User] ( [Id] INT NOT NULL IDENTITY PRIMARY KEY, ... ) CREATE TABLE [dbo].[Address] ( [Id] INT NOT NULL IDENTITY PRIMARY KEY, ... ) CREATE TABLE [dbo].

nHibernate & sqlite mappings

烈酒焚心 提交于 2019-12-23 03:23:35
问题 I'm having real problems with setting up nHibernate with sqlite. Here is the hibernate.cfg.xml file: <?xml version="1.0" encoding="utf-8" ?> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="dialect">NHibernate.Dialect.SQLite20Dialect</property> <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property> <property name=

Updating child instead of deleting it

≯℡__Kan透↙ 提交于 2019-12-23 02:52:45
问题 Look at the entity - class Person { int id { get; set; }; IList<PersonAddress> Addresses { set; get; } ... } Now while updating person from UI if I just remove some addresses from the list of address then I wand to actually delete the address record from db. currently this is updating the address table setting personId = NULL and not deleting the address record. Does anyone know how to do this. may be some mapping issue. Here I am adding whole Person class mapping file. public class

How can I use NHibernate with immutable type like System.Tuple?

时间秒杀一切 提交于 2019-12-22 21:16:29
问题 I have a composite mapping using System.Tuple<int,string> that looks as follows: <composite-element class="System.Tuple`2[[System.Int32, mscorlib],[System.String, mscorlib]], mscorlib"> <property name="Item1" column="DBColumn1"/> <property name="Item2" column="DBColumn2"/> </composite-element> I try messing around with BytecodeProvider , IObjectsFactory , ReflectionOptimizer and whatnot, but I can't get NHibernate to load my Tuple properly (whatever I do, NHibernate insists on creating the

Normalizing EnumStringType in NHibernate

*爱你&永不变心* 提交于 2019-12-22 10:49:45
问题 I am currently using an enumeration in an NHibernate mapped as follows.. public enum UploadMethod { Java, Silverlight, Gears, Flash } class UploadMethodType : EnumStringType { public UploadMethodType() : base(typeof(UploadMethod), 255) { } } public class Person { /* Bunch of non interesting properties... */ public UploadMethod PreferredUploadMethod { get; set; } } <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="Person" lazy="false" table="[dbo].[People]"> <!-- Bunch of non

Fluent NHibernate mapping IList<Point> as value to single column

ぐ巨炮叔叔 提交于 2019-12-22 10:44:00
问题 I have this class: public class MyEntity { public virtual int Id { get; set; } public virtual IList<Point> Vectors { get; set; } } How can I map the Vectors in Fluent NHibernate to a single column (as value)? I was thinking of this: public class Vectors : ISerializable { public IList<Point> Vectors { get; set; } /* Here goes ISerializable implementation */ } public class MyEntity { public virtual int Id { get; set; } public virtual Vectors Vectors { get; set; } } Is it possible to map the

object references an unsaved transient instance save the transient instance before flushing

拈花ヽ惹草 提交于 2019-12-22 09:03:51
问题 i have a self join employees entity class with id,name and ref columns that has relation with it self. i want to create new instance of that and persist it to db. at first i created an instance of Employee class and named it manager. then i fetched a record from Employee table with these values: Id = 1, Name = "A", RefId = null and set those values to manager object. after that i created an instance of Employee class again and set it's properties value like this: emp.Name = "B", emp.Ref =

object references an unsaved transient instance save the transient instance before flushing

我只是一个虾纸丫 提交于 2019-12-22 09:02:34
问题 i have a self join employees entity class with id,name and ref columns that has relation with it self. i want to create new instance of that and persist it to db. at first i created an instance of Employee class and named it manager. then i fetched a record from Employee table with these values: Id = 1, Name = "A", RefId = null and set those values to manager object. after that i created an instance of Employee class again and set it's properties value like this: emp.Name = "B", emp.Ref =

nhibernate does not cascade delete children

时间秒杀一切 提交于 2019-12-22 05:15:14
问题 The scenario is as follows, I have 3 objects (i simplified the names) named Parent, parent's child & child's child parent's child is a set in parent, and child's child is a set in child. mapping is as follows (relevant parts) parent <set name="parentset" table="pc-table" lazy="false" fetch="subselect" cascade="all-delete-orphan" inverse="true"> <key column=FK_ID_PC" on-delete="cascade"/> <one-to-many class="parentchild,parentchild-ns"/> </set> parent's child <set name="childset" table="cc

Fluent NHibernate join not using primary key

我的未来我决定 提交于 2019-12-22 04:39:17
问题 I am trying to get a single property from a joined table where a non-PK in my main table is joined to the PK of the foreign table. Below is an oversimplified example of what I am trying to accomplish ( I do not want to reference the foreign entity ): Tables: CREATE TABLE Status ( Id int, Body text, CategoryId int ) CREATE TABLE Category ( Id int, Name text ) SQL to generate: SELECT Id, Body, CategoryId, Category.Name AS CategoryName FROM Status LEFT JOIN Category ON Category.Id = Status