nhibernate

NHibernate - How to map composite-id with parent child reference

杀马特。学长 韩版系。学妹 提交于 2019-12-25 03:12:09
问题 i have the following scenario (For better illustration, the example is very simplified) Database Model BAS_COSTCODE refers to BAS_CONTEXT. The key for this table is a composite with COSTCODEID and the CONTEXT_FK. CONTEXT_FK refers to BAS_CONTEXT. To build up a hierarchical tree, a CostCode can have a parent. For this reason there is a reference to the table itselfe. The schema file for Context is like that: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate

Product with last 4 vendors on transaction date

瘦欲@ 提交于 2019-12-25 03:11:59
问题 Hi I have this sql and have to translate into NHibernate QueryOver SELECT S.Number, S.Description, S.BrandDescription, subquery.vendornumber, subquery.vendorname FROM Stocks.Stock S left join (select vendorNumber, VendorName, POLID, LastTransactionDate from ( SELECT top 4 v.Number vendorNumber, v.Name VendorName, PLL.Id POLID, max(por.TransactionDate) as LastTransactionDate, ROW_NUMBER() OVER(PARTITION BY v.Number ORDER BY max(por.TransactionDate) DESC) AS rk FROM Purchasing

NHibernate Session in global.asax Application_BeginRequest

£可爱£侵袭症+ 提交于 2019-12-25 03:02:16
问题 I am trying to start a hibernate session in Global.asax and Application_BeginRequest and then access a static SessionFactory on Global.asax to get the current session in a WCF service. However I get "Object reference not set to an instance of an object" when I try to get the current session inside the service. I am accessing the service using basicHttpBinding. Global.asax public class Global : System.Web.HttpApplication { public static ISessionFactory SessionFactory { get; private set; }

NHibernate Session in global.asax Application_BeginRequest

会有一股神秘感。 提交于 2019-12-25 03:01:05
问题 I am trying to start a hibernate session in Global.asax and Application_BeginRequest and then access a static SessionFactory on Global.asax to get the current session in a WCF service. However I get "Object reference not set to an instance of an object" when I try to get the current session inside the service. I am accessing the service using basicHttpBinding. Global.asax public class Global : System.Web.HttpApplication { public static ISessionFactory SessionFactory { get; private set; }

fluent nhibernate foreign key with 2 columns mapping

别来无恙 提交于 2019-12-25 02:59:58
问题 I have to an existing schema and I want to map it with nhibernate. entities / table schema: post { pk_id prod_id prod_internid title } tag { pk_t_id prod_id prod_internid name } A post can have multiple tags and there is a foreign key contraint from the tag to the post table with the two columns prod_id and prod_internid. I've tried this: PostMap { // tags is a list HasMany(x => x.tags).KeyColumns.Add("prod_id", "prod_internid"); } TagMap { References(x => x.post).Columns("prod_id", "prod

NHibernate: Two foreign keys in the same table against same column

落爺英雄遲暮 提交于 2019-12-25 02:57:49
问题 I am working on a consignment booking software. The consignment object has the following structure: public class Consignment { //Other properties public virtual Station FromStation{get;set;} public virtual Station ToStation{get;set;} } and here is the station object: public class Station { public virtual int StationId{get;set;} public virtual string StationName{get;set;} //I don't want this property but I have to keep it. public virtual Iesi.Collections.Generic.ISet<Consginment>

Fill property of DTO with SubQuery in NHibernate Query

痞子三分冷 提交于 2019-12-25 02:55:10
问题 I have a DTO object like this: public class TreeViewDTO { public string Value { get; set; } public string Text { get; set; } public bool HasChildren { get; set; } } and my entity mapped with Nhibernate is: public class Entity { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual Entity Parent { get; set; } /* other properties */ } I would like to know, how can I get a List of my DTOs and fill the HasChildren property using a count method or a subquery

Paging in NHibernate

十年热恋 提交于 2019-12-25 02:47:44
问题 Lets say I have a domain model with a class called Blog that has a property called BlogEntries (that contains objects of type BlogEntry). If I have a database model with two tables "Blog" and "BlogEntry", it's not impossible that I have 1000 blog entries for a blog. If I were to show the blog on a web site, I would only want to display maybe 20 blog entries at a time, so I would have to use some sort of paging. I obviously don't want 1000 records to be fetched from the DB all the time. How

Spring.Net + NHibernate - The 'http://www.springframework.net/database:provider' element is not declared

风流意气都作罢 提交于 2019-12-25 02:45:16
问题 I’m having some Spring and NHibernate issues which nobody seems to be able to resolve. I'm using the NorthWind project as an example to go off of. Right now I’m getting this error: 'MyNamespace.MyClass.MyFunction: Spring.Objects.Factory.ObjectDefinitionStoreException : Line 6 in XML document from assembly [MyAssembly, Version=0.0.1.0, Culture=neutral, PublicKeyToken=334479e19ddfb52d], resource [MyNamespace.Dao.xml] violates the schema. The 'http://www.springframework.net/database:provider'

One-to-one Mapping issue with NHibernate/Fluent: Foreign Key not updateing

梦想与她 提交于 2019-12-25 02:44:51
问题 Summary: Parent and Child class. One to one relationship between the Parent and Child. Parent has a FK property which references the primary key of the Child. Code as follows: public class NHTestParent { public virtual Guid NHTestParentId { get; set; } public virtual Guid ChildId { get { return ChildRef.NHTestChildId; } set { } } public virtual string ParentName { get; set; } protected NHTestChild _childRef; public virtual NHTestChild ChildRef { get { if (_childRef == null) _childRef = new