nhibernate

Left join in linq in NHibernate 3.2

坚强是说给别人听的谎言 提交于 2019-12-23 13:28:44
问题 Is it possible to implement left join in linq in NHibernate 3.2 ? I want to achive a linq query similar to this sql query: select v.*, cp.EffectiveStart from Visits v join VisitServices vs on v.Id = vs.VisitId left join CarePlans cp on cp.Id = vs.CarePlanId I have written such linq query: var c = (from v in EntitiesRepository join vs in _visitServiceRepository on v.Id equals vs.Visit.Id join cp in _carePlanRepository on vs.CarePlan.Id equals cp.Id into pp from pl in pp.DefaultIfEmpty() select

How long can/should an NHibernate session be kept open?

 ̄綄美尐妖づ 提交于 2019-12-23 12:58:10
问题 I've created a windows service which is listening to a MSMQ. For each message I receive, some DB transactions need to be made. Later it might be possible that there will be 1 message every second. Currently the Nhib session is kept open until the service is stopped manually. Is it a good practice or should I close the session after each message? Thanks in advance 回答1: An NHibernate session is meant to be relatively short lived, so its generally not a good idea to keep it active for a longer

Mapping two references in the same class but reference class has Composite key

六月ゝ 毕业季﹏ 提交于 2019-12-23 12:43:42
问题 I have the following database tables (These are abbreviated for clarity): CREATE TABLE [dbo].[prod_uom]( [prod_id] [dbo].[uid] NOT NULL, --Primary key [uom_type] [numeric](9, 0) NOT NULL, --Primary Key ) CREATE TABLE [dbo].[order_line]( [order_line_id] [dbo].[uid] NOT NULL, --Primary key [prod_id] [dbo].[uid] NOT NULL, --Foreign key [uom_type_requested] [numeric](9, 0) NOT NULL, --Foreign key [uom_specified] [numeric](9, 0) NOT NULL --Foreign key ) Entity I'm having trouble with looks like

Fluent NHibernate mapping to a SQL Server CHAR(10) ID column

旧巷老猫 提交于 2019-12-23 12:32:28
问题 New to both NHibernate and Fluent NHibernate and I'm trying to resolve a performance problem in some inherited code caused by a conversion of a CHAR(10) column to NVARCHAR . From SQL Profiler: exec sp_executesql N'select mytestclas0_.LinkId as LinkId45_, mytestclas0_.Href as Href45_, mytestclas0_.LinkActive as LinkActive45_ from MessageLinks mytestclas0_ where mytestclas0_.LinkId=@p0',N'@p0 nvarchar(4000)',@p0=N'BzE2T48HMF' You can see the ID coming in from NHibernate is cast as a NVARCHAR .

Error loading one of the NHibernate dependent dll's

左心房为你撑大大i 提交于 2019-12-23 12:29:18
问题 I am building an application using NHibernate. Because I could not add the DLL's of my current version of NHibernate (I cannot add reference when framework 4.0 is target). I tried to get the latest and greatest of the w.w.w., this is what I have now: NHibernate.dll (3.2.0.4000) NHibernate.ByteCode.Castle (3.0.0.4000) FluentNHibernate.dll (1.2.0.694) Castle.Core (2.5.2.0) Castle.Services.Logging.NLogIntegration (2.5.2.0) Antlr.Runtim (3.1.3.42154) Iesi.Collections (3.2.0.400) These I can

NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException

浪尽此生 提交于 2019-12-23 12:25:02
问题 I have the following code set up in my Startup IDictionary<string, string> properties = new Dictionary<string, string>(); properties.Add("connection.driver_class", "NHibernate.Driver.SqlClientDriver"); properties.Add("dialect", "NHibernate.Dialect.MsSql2005Dialect"); properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"); properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider"); properties.Add(

LINQ-NHibernate - Selecting only a few fields (including a Collection) for a complex object

坚强是说给别人听的谎言 提交于 2019-12-23 12:20:57
问题 I'm using Fluent NHibernate in one of my projects (and ASP.NET MVC application), with LINQ to query to data (using the LINQ to NHibernate libraries). The objet names are changed to protect the innocent. Let's say I have the following classes Foo, Bar, Baz, and their appropriate tables in the database (MySQL). Foo has a many-to-many relationship with both Bar (table "FooBar") and Baz (table "FooBaz"), defined in the Fluent mappings. As such, the class interface is defined as follows: public

key-many-to-one and key-property association: nhibernate won't DELETE items from set

耗尽温柔 提交于 2019-12-23 12:19:43
问题 I'll try to keep this terse, but hopefully won't miss any important information in my troubles. The code I believe provides all details, but I've left out the noise (it's VB, so there's lots of noise :) ). A "Case" object has many "Assignments": Public Class Case Property CaseId As Guid Property Assignments As ISet(Of CaseAssignment) End Class Public Class CaseAssignment Property Case As Case Property RoleId As Guid End Class The data model I've been handed looks about like what you'd expect,

Could not find the property - exception after switching from NHibernate 3 to 3.3.1

跟風遠走 提交于 2019-12-23 12:08:07
问题 I have a class with a field: protected DateTime insertDate; This is mapping for this fiels: <property name="InsertDate" access="field.camelcase" update="false" /> This field is set when with ctor public DocuBase(DateTime insertDate) and is persisted only when row is added to the database. I don't need property for it at all, no setter & no getter. I worked in NHibernate 3. And now, I've moved from NHiberbate 3 to NHibernate 3.3.1, and I get this exception when session factory is created:

Best practices to convert a NHibernate app as multi-tenant?

懵懂的女人 提交于 2019-12-23 12:05:14
问题 I have a simple ASP.NET MVC + OpenID + NHibernate app (on top of MSSQL Server DB). The app is strictly single tenant and supports multiple users with only 2 roles ( Admin and User ). I would like to convert this app into a multi-tenant app. My requirements are limited: I just need to introduce the notion of Account s, each account having its own set of users and behaving exactly like the original non-multi-tenant app. There is no interactions between accounts. What are the best practices to