fluent-nhibernate

Can't get Fluent nHibernate to work with Subclasses

落爺英雄遲暮 提交于 2019-12-13 08:27:44
问题 So I would like to have a BaseEntity which contains common columns that appear in all tables and use inheritance to keep mapping of these fields in one place. For the sake of simplicity I will only include one field (Id). The code looks as follows: [Serializable] public abstract class BaseEntity { public Guid Id { get; set; } } public class Hedge : BaseEntity { public virtual DateTime HedgeDate { get; set; } public virtual DateTime SettleDate { get; set; } } public class Trade : BaseEntity {

DDD - Mapping Value Objects with Fluent nHibernate in separate tables

浪子不回头ぞ 提交于 2019-12-13 06:56:50
问题 EDIT: Hi, trying an edit to get this question answered. In order to try improve the question, here is a straight to the point condensed version: Is the code below the way to go when mapping value objects to separate tables using fluent nhibernate, or is there an alternative? Hi, For the purpose of this question I am using nhibernate fluently configured. I'm steadily learning DDD but am after some clarification with the mapping of value objects. There seems to be a lot of information regarding

Remote Database response very slow of asp.net application using NHIbernate

旧时模样 提交于 2019-12-13 06:48:19
问题 I may be missed something to track in the bellow code, but it is slowing down remote database server response time. Application is working fine while tried with Database from the same machine where application deployed. Also, verified all the nHibernate tasks using NH-Profiler. All queries are under controlled. The only reason is response time of DB server. Also, analyzed the DB server, server is fine but this is the only application which is slow while running through Remote Database server.

Fluent NHibernate join for property value

依然范特西╮ 提交于 2019-12-13 05:44:33
问题 I'm trying to join a table to retreive and set a property on a POCO. Here's the scenario... *NOTE - An application can belong to many user sessions. UserSession (Table) UserSessionId PK ApplicationId FK UserName Application (Table) ApplicationId PK Name UserSession (Poco) string UserName get; string ApplicationName get; I've tried a join like this: Join("Application", j => j.Inverse().KeyColumn("ApplicationId").Map(x => x.ApplicationName)); However, this uses the primary column of the

NHibernate cannot resolve property of one to one mapping when used in a filter

冷暖自知 提交于 2019-12-13 05:08:01
问题 Ok I've got to be doing something really stupid, but I just can't see what it is. I have the following query: Recipes recipe = null; var q = session.QueryOver<Recipes>(() => recipe) .Where(p => p.Metadata.SkillCommon) .Where(p => !p.Hidden); The Recipes model has a property called Metadata which is a one-to-one mapping to the RecipeMetadata model. In other words, every recipe has one and only one RecipeMetadata. It's mapped like so: HasOne(x => x.Metadata); When I run this query, I get the

NHibernate: Cannot assign property value in entity's constructor

瘦欲@ 提交于 2019-12-13 04:59:51
问题 When I run the following code, at B's constructor, I got a NullReferenceException. I cannot assign value to B's Number property. Models: public class A { public A() { this.Number = 1; if (this.Number != 1) { throw new Exception("Failed to assign value in A's constructor"); } } public virtual int Id { get; private set; } public virtual int Number { get; set; } public virtual B B { get; set; } } public class B { public B() { this.Number = 1; // Throws NullReferenceException: Object reference

Fluent nhibernate batch save

跟風遠走 提交于 2019-12-13 04:42:22
问题 I have xml file that I am reading in and uppdating existing records in a database. I read the xml into a list of c# objects and iterate through them finding the corresponding record in the datbase and update it from the xml/c# values. I then save this object - but is there any way in fluent nihibernate to add the object to a list ( could be 1000s of records) and bacth save Bottom line it is performance I am afer - I have been using subsonic 2 and 3 and have opted for subsonic 2 as it was way

Loading a base class through nhibernate incorrectly uses mappings from derived classes

狂风中的少年 提交于 2019-12-13 01:58:22
问题 I have a scenario where I have a base class as one entity, then another entity that derives from the other base class. Both have meaning in my domain and can be used separately. public class MyBaseClass { int ID { get; set; } string Name { get; set; } } public class MyChildClass { string AdditionalField { get; set; } } I have both mapped using Fluent nHibernate using ClassMap like this: public class MyBaseClassMap : ClassMap<MyBaseClass> { Id("MyBaseClassID"); Map(x => x.Name); } public class

NHibernate QueryOver with leftjoins

纵然是瞬间 提交于 2019-12-13 00:36:30
问题 This thing is keeping me busy for days and I hope someone of the NHibernate gurus can help me out. I've got a query set up which is working in SQL Server and I want to get the same in NHibernate. But all my tries (did a lot of googeling and browsing in stackoverflow) failed so far. Here's the query: Select j.id, j.title, j.company, jt.name as category, loc.city, je.is_assigned, FROM job j LEFT JOIN location loc ON loc.id = j.location LEFT JOIN job_tag jt ON jt.job = j.id and jt.name in

FluentNHibernate Lookup Table

喜欢而已 提交于 2019-12-13 00:25:25
问题 This is possibly an easy one that I can't seem to get past. I've created a "Product" class which has a list of "Accessories". Each "Accessory" is just another product referenced by a lookup table. Table setup: Product ------- ProductID int Name varchar(200) AccessoryProduct ---------------- ID int ParentProductID int ChildProductID int I'd like to be able to access this list of accessories in a manner such as: foreach(Product p in product.Accessories) string s = p.Name; The part I'm stumped