fluent-nhibernate-mapping

Fluent NHibernate - how to create table-per-subclass mapping using a discriminator?

守給你的承諾、 提交于 2019-12-11 01:56:25
问题 I've looked at a lot of questions on SO and google regarding sub-class mappings in nhibernate / fluent-nhibernate and not managed to find anyone with the same problem as me. I've followed the basic instructions from the fluent-nhibernate wiki (http://wiki.fluentnhibernate.org/Fluent_mapping#Subclasses) but this hasn't helped. I have a base entity called Operation - which has a base table associated with it, I then have sub-tables UnpaidCheque, Refund etc - the primary key for each of these

Mapping clobs using Fluent NHibernate, Oracle 10g and OracleClientConfiguration.Oracle10

随声附和 提交于 2019-12-10 18:44:24
问题 I've been trying to map a clob field using Fluent NHibernate 1.2.0.712 against Oracle 10g. I'm using System.Data provider as it's available by default and was trying to avoid adding reference to ODP.Net due to previous client issues. However, when I try to insert entities with mapped clob properties, I get the error: ORA-01461: can bind a LONG value only for insert into a LONG column I've tried to fix this by using the below convention, and decorating the appropriate property with

Mapping a flat view to class hierarchy in fluent nHibernate

本小妞迷上赌 提交于 2019-12-10 15:45:23
问题 I'm developing an app that has a model using race results / times etc.. I've got a model that looks something like: public class Competitor { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual DateTime DateOfBirth { get; set; } } public class Event { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual string Description { get; set; } } public class Result { public virtual int ID { get; set; } public virtual

Defining a Derived Boolean Property using Fluent NHibernate

£可爱£侵袭症+ 提交于 2019-12-10 15:39:11
问题 I have a class public class Account { public DateTime? StartDate {get;set;} public DateTime? EndDate {get;set;} public bool IsActive {get;set;} } the IsActive property is defined as a formula as .Formula(" StartDate < GETDATE() and (EndDate is NULL or EndDate > GetDate())") However when use QueryOver to query all Accounts where the IsActive == true I get an error that NHibernate cannot execute a SQL. The SQL that NHibernate generates has ...other criterias... and this_.StartDate < GETDATE()

NHibernate Save Is Trying to Clear Child KeyColumn Id On Update

对着背影说爱祢 提交于 2019-12-10 10:34:18
问题 I am trying to create a parent object that has multiple children in a 1 to many relationship. I am not referencing the Parent object on the child object, instead I am mapping its keycolumn as a field. When I try to save this object for the first time, it works as expected without any issues (cascading all the Id's and children). When I try to get the object from the database, update some properties on it and re-save it again, it fails. The actual error message I am getting is "Could not

Setting up one to many relationship with Fluent Nhibernate

跟風遠走 提交于 2019-12-09 13:09:30
问题 I'm having a bit of an argument with my co-worker that I can't seem to find an answer to yet this is very basic stuff. Establishing one-to-many relationship in Fluent Nhibernate entity. Let's take Roles and users for example. A role can be assigned to multiple users so I made my entity guts looks like: public class User { [Required] public virtual string FirstName { get; set; } public virtual Role Role { get; set; } } and role public class Role { [Required] public virtual string Name { get;

Fluent NHibernate one-to-many relationship setting foreign key to null

∥☆過路亽.° 提交于 2019-12-09 13:05:22
问题 I have a simple Fluent NHibernate model with two related classes: public class Applicant { public Applicant() { Tags = new List<Tag>(); } public virtual int Id { get; set; } //other fields removed for sake of example public virtual IList<Tag> Tags { get; protected set; } public virtual void AddTag(Tag tag) { tag.Applicant = this; Tags.Add(tag); } } public class Tag { public virtual int Id { get; protected set; } public virtual string TagName { get; set; } public virtual Applicant Applicant {

NHibernate - Force escaping on Table Names

别来无恙 提交于 2019-12-07 03:05:40
问题 Are there any good examples of how to use this (NHibernate.Criterion.IdentifierEqExpression) online? I couldn't find any. I'm a little confused about what you are supposed to pass into the constructor. I pass in an int32 of 1 and I keep thinking my test should basically do a "where id = 1" type of query and instead it blows up with "where id = ?" and something about positional parameters. If that's not what is supposed to be passed into the constructor ... what is? Real Issue When I look at

Fluent NHibernate Inheritance mapping type

故事扮演 提交于 2019-12-06 14:38:12
I'm new to Fluent NHibernate, thus far I managed to get my mapping working except for the inheritance part. Is there anybody who could help me finish the mapping? I have simplified the code as much as possible. Thank you! My database: CREATE TABLE [User] ( UserID INT NOT NULL IDENTITY(1,1), Type CHAR(1) NOT NULL, Email VARCHAR(255) NOT NULL, PRIMARY KEY(UserID) ); CREATE TABLE [Student] ( UserID INT NOT NULL, Firstname VARCHAR(255) NOT NULL, PRIMARY KEY(UserID), FOREIGN KEY(UserID) REFERENCES [User](UserID) ); CREATE TABLE [Company] ( UserID INT NOT NULL, Name VARCHAR(255) NOT NULL, PRIMARY

NHibernate Save Is Trying to Clear Child KeyColumn Id On Update

流过昼夜 提交于 2019-12-06 06:31:20
I am trying to create a parent object that has multiple children in a 1 to many relationship. I am not referencing the Parent object on the child object, instead I am mapping its keycolumn as a field. When I try to save this object for the first time, it works as expected without any issues (cascading all the Id's and children). When I try to get the object from the database, update some properties on it and re-save it again, it fails. The actual error message I am getting is "Could not delete collection". The error above is due to the fact that it is trying to set the "ParentId" field on the