nhibernate

Inheritance and lazy loading in NHibernate

耗尽温柔 提交于 2019-12-23 05:06:13
问题 Take the following classes: public class Employee { public Employee Manager { get; set; } } public class ShopFloorEmployee : Employee { ... } public class OfficeEmployee : Employee { ... } public class Department { public Employee Manager { get; set; } } and here are the NHibernate mapping files: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Domain.Entities" assembly="Domain"> <class name="Employee"> <id name="Id" column="Id" type=

Session-per-HttpRequest using Autofac. NHProf showing “multiple Session” warning when not accessing ISession through DependencyResolver

本小妞迷上赌 提交于 2019-12-23 05:05:07
问题 I've successfully implemented Session-per-HttpRequest using Autofac. I'm unhappy with my implementation because I am going through DependencyResolver and not relying on parameters provided by AutoFac. If I rely on the ISession parameter provided by AutoFac, then I receive a warning with NHProf indicating that there are multiple Sessions in use. If I go through DependencyResolver , the warning from NHProf disappears, but the usage feels incorrect to me. I have followed the Autofac + MVC4.0

Entity Framework vs alternatives

核能气质少年 提交于 2019-12-23 04:36:13
问题 Duplicate: What ORM frameworks for .NET Do You Like Best? What are you currently using for data access? When choosing an ORM, is LINQ to SQL or LINQ to Entities better than NHibernate? Database (and ORM) choice for an small-medium size .NET Application Etc. What OR\M would you recommend for a large ASP.NET application, Entity Framework or NHibernate. What do you consider to be the advantages and disadvantages specific to both technologies? 回答1: I put together a fairly lengthy answer to a

What is the best way to dynamically add to a where clause in a nhibernate query in C#?

↘锁芯ラ 提交于 2019-12-23 04:12:33
问题 I have a some C# code that is querying a database using nhibernate that looks like this: public void Query() { IEnumerable<Project> list = session.Query<Project>() .Where(p => !p.IsDeleted) .FetchMany(r => r.UnfilteredProjectApplications) .ThenFetch(r => r.Application) .ToList() } I now have a number of user driver filters so, based on the parameters passed in, i want to add to the where clause. So something like this: public void Query(string name) { if (!String.IsNullOrEmpty(name) {

Error using $expand with NHibernate and webapi + OData

删除回忆录丶 提交于 2019-12-23 03:57:17
问题 When you run the query {{odata-url-prefix}}/ArquivosVenda(2)?$expand=Vendas an error is generated: { "odata.error": { "code": "", "message": { "lang": "en-US", "value": "An error has occurred." }, "innererror": { "message": "Argument types do not match", "type": "System.ArgumentException", "stacktrace": " at System.Web.Http.ApiController.<InvokeActionWithExceptionFilters>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime

ASP.NET MVC application when deployed to IIS 7 in integrated mode using NHibernate data will not load

跟風遠走 提交于 2019-12-23 03:49:29
问题 We have built an ASP.NET MVC application which utilizes NHibernate, the MVCContrib version of StructureMap, and an onion architecture as outlined by Jeffery Palermo in ASP.NET MVC in Action. This application works well when running locally from Visual Studio 2008. The Index action on our Home controller loads a view which immediately pulls data from the database utilizing the tools as outlined above. When running on IIS 6 or in Classic Mode on IIS 7 this section of the page loads data. Of

How to efficiently query with filter on children at different levels?

不问归期 提交于 2019-12-23 03:46:16
问题 I have 3 classes with one to many relationships A has many B has many C I want to load all of my data where either of two conditions are true: B.someField is in a list of strings C.someOtherField is in that same list of strings Sometimes B will be the match, sometimes C will be the match. I need to load all matches, and load them for the full levels. In other words, if B.someField matches, I want to load that B, and its parent A, and all children C. Likewise, if C.someOtherField matches, I

NHibernate add unmapped column in interceptor

时光怂恿深爱的人放手 提交于 2019-12-23 03:42:09
问题 I'm trying to save a mapped entity using NHibernate but my insert to the database fails because the underlying table has a column that does not allow nulls and IS NOT mapped in my domain object. The reason it isn't mapped is because the column in question supports a legacy application and has no relevance to my application - so I'd like to not pollute my entity with the legacy property. I know I could use a private field inside my class - but this still feels nasty to me. I've read that I can

NHibernate add unmapped column in interceptor

三世轮回 提交于 2019-12-23 03:42:03
问题 I'm trying to save a mapped entity using NHibernate but my insert to the database fails because the underlying table has a column that does not allow nulls and IS NOT mapped in my domain object. The reason it isn't mapped is because the column in question supports a legacy application and has no relevance to my application - so I'd like to not pollute my entity with the legacy property. I know I could use a private field inside my class - but this still feels nasty to me. I've read that I can

Mixing Likes and Equals with NHibernate Query-By-Example?

安稳与你 提交于 2019-12-23 03:37:23
问题 I have a rather large SOA solution and a newly added service queries approx 9.8 million records using NHibernate's Query By Example. Thus far the performance has been terrible, and a profile on the database shows the query as: exec sp_executesql N'SELECT this_.Id as Id3_0_, this_.ESIID as ESIID3_0_, this_.ADDRESS as ADDRESS3_0_, this_.ADDRESS_OVERFLOW as ADDRESS4_3_0_, this_.CITY as CITY3_0_, this_.STATE as STATE3_0_, this_.ZIP5 as ZIP7_3_0_, this_.ZIP4 as ZIP8_3_0_, this_.DUNS as DUNS3_0_,