fluent-nhibernate

wont save to database with guid as id- fluent-nhiberate

不羁岁月 提交于 2019-12-24 11:56:23
问题 i got problems with saving when i use Guid as identifier. can anybody se what i am missing here? i create my own guid so i dont want it to be generated by database. NOTE: i have tried the guid.combo in mapping to without any success. public class Order { public virtual Guid Id { get; set; } public virtual ICollection<OrderItem> OrderItems { get; set; } public virtual User User { get; set; } public virtual DateTime? CreateDate { get; set; } public virtual DateTime? ShippedDate { get; set; }

nHibernate- a Collection which would contain only a supertype

核能气质少年 提交于 2019-12-24 11:53:03
问题 I have the following classes: class Employee { public string Name { get; set; } } class HistoricalEmployee : Employee { public DateTime TerminationDate { get; set; } } class Company { public IList<Person> CurrentEmployees { get; set; } } Employee and HistoricalEmployee are mapped using table-per-class-heirarchy strategy. When I retrieve the CurrentEmployees collection, I want it only to contain elements that are Employee, and NOT HistoricalEmployees. when an employee 'dies', they're not

nHibernate- a Collection which would contain only a supertype

二次信任 提交于 2019-12-24 11:48:21
问题 I have the following classes: class Employee { public string Name { get; set; } } class HistoricalEmployee : Employee { public DateTime TerminationDate { get; set; } } class Company { public IList<Person> CurrentEmployees { get; set; } } Employee and HistoricalEmployee are mapped using table-per-class-heirarchy strategy. When I retrieve the CurrentEmployees collection, I want it only to contain elements that are Employee, and NOT HistoricalEmployees. when an employee 'dies', they're not

FluentNHibernate and primitive type collection

北城余情 提交于 2019-12-24 11:37:41
问题 I'm having trouble persisting primitive type collection using (Fluent)NHibernate. Here's the entity and mapping: public class SomeOne { public virtual long ID { get; set; } public virtual string Name { get; set; } public virtual string Description { get; set; } public virtual Iesi.Collections.Generic.ISet<string> Foo { get; protected set; } public SomeOne() { Foo = new HashedSet<string>(); } } public SomeOneMap() { Id(x => x.ID).GeneratedBy.Identity(); Map(x => x.Name); Map(x => x.Description

fluent nHibernate: How to persist a property which is mapped with Formula?

自闭症网瘾萝莉.ら 提交于 2019-12-24 10:31:06
问题 I am dealing with a legacy database, and we have a field which doesn't make sense anymore, but I would rather not change the DB schema. I'm trying to map an old DB text field into a class with a boolean (only need to know about one option that the DB text field has). I can get the boolean value out of the DB using Forumla, but I can seem to get it to save any updates back into the DB. My class and current fluent mapping for it is: public class Bulletin { public virtual int Id { get; set;}

How to create dynamic NHibernate mappings without generating HBM XML files?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 09:06:55
问题 I'm working on a dynamic application with NHibernate. My goal is to create dynamic entities (both class type and mapping xml file) based on some data. For example suppose I want to create a Person entity dynamically in runtime and on the fly. I use Reflection.Emit to generate class type dynamically. For creating mapping dynamically I used Ayende's code.. But unfortunately this code does not work because mappings does not have Classes property. I tried to code as same as codes of Castle

Skip property on update in NHibernate

。_饼干妹妹 提交于 2019-12-24 08:22:53
问题 Say I have an User entity and it haves a Password property which is not nullable : Map((x) => x.Password).Column("PASSWORD").Not.Nullable(); In the create action, I manually set the Password value as it is a generated hash. It never goes to the View. In the update, I try to save it, but I don't have the Password value. I get this error for Password propery: PropertyValueException: not-null property references a null or transient value This is my Update method: public bool Update(UserViewModel

(Fluent) NHibernate: Map complete table to one object

橙三吉。 提交于 2019-12-24 07:25:26
问题 I have the following database table: Settings Key | Value ---------------|------------------- SomeSetting | Foo AnotherSetting | Bar ... | ... And want to map this to the following object: public class Settings { public virtual string SomeSetting { get; set; } public virtual string AnotherSetting { get; set; } } How could I accomplish this using (Fluent) NHibernate? 回答1: I would map the key/value pairs to a private IDictionary and expose the properties by accessing the dictionary. See Ayende

Composite key with sequence

大城市里の小女人 提交于 2019-12-24 06:49:16
问题 I have a composite key in my table and part of it needs to be generated by a sequence. I tried the following, but it doesn't work - the line that sets the sequence name seems to be overridden by the composite key declaration that follows: mapping.Id(x => x.Id).GeneratedBy.SequenceIdentity("SQ_TRANSFORM_ITEMDEL_IDDID"); mapping.CompositeId().KeyProperty(x => x.Id, "ITEMDELIVERYDETAIL_ID") .KeyReference(x => x.ItemDelivery, "ITEMDELIVERY_ID", "PARTITIONDATE"); How to solve that problem? 回答1:

Inserting byte[0] into a NOT NULLABLE column in Oracle DB Table

↘锁芯ラ 提交于 2019-12-24 06:35:20
问题 I have a table DOCUMENTS in Oracle DB with the below description create table DOCUMENTS ( DOC_ID NUMBER not null, DOCUMENT BLOB not null, DOC_URL VARCHAR2(4000) ) This is a simple table which is used to store images from multiple sources. From one of the source, the requirement is to just insert the HTTP Path of the image without the DOCUMENT (Document would be NULL). As the column is defined as NOT NULL in the table, I was trying to overcome the constraint by inserting an empty blob into the