nhibernate

Rehydrating fluent nhibernate configured DateTime as Kind Utc rather than Unspecified

寵の児 提交于 2019-12-29 03:37:08
问题 Is there a way in fluent nhibernate to map a DateTime to rehydrate my entity with DateTime.Kind set to Utc rather than unspecified? I'm currently persisting a DateTime that is Utc, but the Kind coming back is always Unspecified, throwing off my time. 回答1: This isn't specific to fluent, but is fundamental to the NHibernate mapping. We use an interceptor to specify the Kind. It is similar to the approach in this blog post which lists a couple alternatives. There is also a proposed patch (NH

Set up caching on entities and relationships in Fluent Nhibernate?

。_饼干妹妹 提交于 2019-12-29 02:46:07
问题 Does anyone have an example how to set up and what entities to cache in fluent nhibernate. Both using fluent mapping and auto mapping? And the same for entity relationships, both one-to-many and many-to-many? 回答1: I have been working a a similar situation, where I just want to cache specific elements, and want these elements to be loaded once on start up, and kept in cache, until the application is shut down. This is a read only cache, and is used to populate a list of countries, so that a

NuGet: NHibernate, Castle.Core 3.0 and where is ProxyFactoryFactory?

柔情痞子 提交于 2019-12-28 13:57:20
问题 I installed with NuGet the packages NHibernate and Castle.Core 3.0 for a new project. Usually we copied around the dlls manually; it is the first time I do that with NuGet. Now I can't find out how to configure the ProxyFactoryFactory, or let's say, I can't find it. I referenced NHibernate and Castle.Core (the only dll I could find in the Castle.Core - package) within the project, and configured the following: <property name="proxyfactory.factory_class"> NHibernate.ByteCode.Castle

NuGet: NHibernate, Castle.Core 3.0 and where is ProxyFactoryFactory?

无人久伴 提交于 2019-12-28 13:56:39
问题 I installed with NuGet the packages NHibernate and Castle.Core 3.0 for a new project. Usually we copied around the dlls manually; it is the first time I do that with NuGet. Now I can't find out how to configure the ProxyFactoryFactory, or let's say, I can't find it. I referenced NHibernate and Castle.Core (the only dll I could find in the Castle.Core - package) within the project, and configured the following: <property name="proxyfactory.factory_class"> NHibernate.ByteCode.Castle

Can I tell if a property is dirty using nhibernate?

我们两清 提交于 2019-12-28 13:41:34
问题 Does anyone know if it is possible to tell if a specific property on an object is dirty (i.e. the property is different to the one stored on the DB) using NHibernate? The background to this question is that I will have an object with a (relatively) large number of properties on it. I need to be able to pass a parameter (string) to a function that will determine if that specific property has changed during the lifetime of the page. If I need to I can create a copy of the object and use

How to implement session-per-request pattern in asp.net mvc with Nhibernate

淺唱寂寞╮ 提交于 2019-12-28 07:07:18
问题 I created the nhibernate session in Application_start event of global.asax file,the session is being passed to constructors of service methods. In the service method I am using the session to do CRUD operations, this works fine.However, When multiple requests or parallel transactions occuring nhibernate is throwing some exceptions.After reading forums i came to know that Nhibernate session is not thread safe.How to make it thread safe and let my application (ASP.NET mvc) work with parallel

How to create a Multi-Column Index or Unique Constraint with NHibernate

非 Y 不嫁゛ 提交于 2019-12-28 05:51:45
问题 How to create a Multi-Column Index and/or Unique Constraint using NHibernate Mapping or Fluent NHibernate. 回答1: assign a index/unique constraint name to more then one property <property name="A" index="AB" /> <property name="B" index="AB" /> Theoretical it would also work with having more then one index on the same entity: <property name="A" index="AB, ABC" /> <property name="B" index="AB, ABC" /> <property name="C" index="ABC" /> But there is a bug. I also wrote a patch. if you are

NHibernate configuration for uni-directional one-to-many relation

橙三吉。 提交于 2019-12-28 02:44:19
问题 I'm trying to set up a relationship as follows. Each Master item has one or more Detail items: public class Detail { public virtual Guid DetailId { get; set; } public virtual string Name { get; set; } } public class Master { public virtual Guid MasterId { get; set; } public virtual string Name { get; set; } public virtual IList<Detail> Details { get; set; } } And Mappings: public class MasterMap : ClassMap<Master> { public MasterMap() { Id(x => x.MasterId); Map(x => x.Name); HasMany(x => x

Polymorphism: Is ORM entity a Domain Entity or Data Entity?

ぐ巨炮叔叔 提交于 2019-12-28 02:16:04
问题 I have a BankAccount table. LINQ to SQL generates a class named “BankAccount” as shown below. [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.BankAccount")] public partial class BankAccount : INotifyPropertyChanging, INotifyPropertyChanged Now, being a newbie, I am newly creating the domain objects myself. Please see IBankAccount interface and FixedBankAccount class. The key point is there is polymorphic behavior – the IBankAccount can be FixedBankAccount or SavingsBankAccount. For

Batch Update in NHibernate

旧街凉风 提交于 2019-12-28 02:06:36
问题 Does batch update command exist in NHibernate? As far as I am aware it doesn't. So what's the best way to handle this situation? I would like to do the following: Fetch a list of objects ( let's call them a list of users, List<User> ) from the database Change the properties of those objects, ( Users.Foreach(User=>User.Country="Antartica" ) Update each item back individually ( Users.Foreach(User=>NHibernate.Session.Update(User) ). Call Session.Flush to update the database. Is this a good