fluent-nhibernate

NHibernate: How to set DynamicUpdate on all Entities?

旧街凉风 提交于 2019-12-24 05:59:17
问题 How can I set DynamicUpdate and DynamicInsert on all my entities? It works perfectly when I put it together with my mapping code, but I would like to specify it only once for my entire project. I could not find an option when creating the Session or in the Configuration. Any ideas? 回答1: I use fluent nhibernate so I would change them like this: var fluentConfiguration = Fluently.Configure(NHibernate.Cfg.Configuration().Configure()) .Mappings(m => m.FluentMappings .AddFromAssemblyOf<OrderMap>()

could not insert select SCOPE_IDENTITY() fluent nhibernate one to many

自古美人都是妖i 提交于 2019-12-24 04:22:14
问题 I have an error exception: "could not insert select SCOPE_IDENTITY()". After certain hours of googling, I found that I have a mistake in my Mapping files. I tried all the possible solutions, but the error keeps appearing. My mapping files: public sealed class EmployeeMap : ClassMap<Employee> { public EmployeeMap() { Table("dbo.Employee"); Id(x => x.Id).Column("EmployeeId"); Map(x => x.Name); Map(x => x.Job); HasMany(x => x.Phones).KeyColumn("EmployeeId").Table("dbo.Phone") .Inverse() .Cascade

C# NHibernate Simple Question

ぃ、小莉子 提交于 2019-12-24 04:12:45
问题 I'm using NHibernate -driven repository, Fluent mappings and attempt to use Linq to NHibernate . But for some simple query like this Retrieve<XValue>(x => (x.Timestamp.CompareTo(start) >= 0 && x.Timestamp.CompareTo(end) <= 0 )); // 'Retrieve' here acts simply as 'session.Query<T>().Where(expression);' I get the following result: System.NotSupportedException: Int32 CompareTo(System.DateTime) I don't know why, but CompareTo operations aren't projected to the database and the output is also kind

KitchenPC and Ironpython

冷暖自知 提交于 2019-12-24 04:03:18
问题 I am attempting to work with KitchenPC using IronPython. I am working with the Database Provisioning example here: http://blog.kitchenpc.com/2014/02/11/kitchenpc-database-provisioning-101/ I am successfully referencing and importing all the dlls and their namespaces: import clr clr.AddReference("System") from System import * from System.Reflection import * from System.Reflection import Assembly L4N = Assembly.LoadFrom('C://KitchenPC//DLL//log4net.dll') clr.AddReference(L4N) NU= Assembly

KitchenPC and Ironpython

青春壹個敷衍的年華 提交于 2019-12-24 04:03:08
问题 I am attempting to work with KitchenPC using IronPython. I am working with the Database Provisioning example here: http://blog.kitchenpc.com/2014/02/11/kitchenpc-database-provisioning-101/ I am successfully referencing and importing all the dlls and their namespaces: import clr clr.AddReference("System") from System import * from System.Reflection import * from System.Reflection import Assembly L4N = Assembly.LoadFrom('C://KitchenPC//DLL//log4net.dll') clr.AddReference(L4N) NU= Assembly

Fluent NHibernate table-per-class-hierarchy need to use .Where()?

江枫思渺然 提交于 2019-12-24 03:53:28
问题 I have the following mapping for a set of contact classes based off an abstract Contact class implementation. public class ContactMapping : ClassMap<Contact> { public ContactMapping() { Id(x => x.Id).GeneratedBy.GuidComb(); Map(x => x.CreatedDate).Not.Nullable(); Map(x => x.Value).Not.Nullable(); Map(x => x.Level).Not.Nullable(); Map(x => x.Comments); DiscriminateSubClassesOnColumn("ContactType"); } } public class PhoneContactMapping : SubclassMap<PhoneContact> { public PhoneContactMapping()

(Fluent) NHibernate mapping for class with calculated properties

╄→尐↘猪︶ㄣ 提交于 2019-12-24 03:28:09
问题 I have the a class similar to the following (nb! names have been changed to protect the innocent): public class Person { public virtual int Id { get; private set; } public virtual string Name { get; set; } public virtual DateTime Birthday { get; set; } public virtual TimeSpan Age { get { return DateTime.Now - this.Birthday; } } } I use Fluent NHibernate to configure my mapping: public class PersonMap : ClassMap<Person> { public PersonMap() { Id(x => x.Id); Map(x => x.Name); Map(x => x

Querying via NHibernate without an N+1 - sample included

谁都会走 提交于 2019-12-24 03:22:29
问题 I have an N+1 problem and I'm not sure how to solve it. A fully-reproducible sample may be found at the bottom of this question. So if you are willing, please create the database, set up the NUnit test and all the accompanying classes, and try to eliminate the N+1 locally. This is the anonymized version of a real problem I encountered. For all you know, this code is crucial in helping launch the next space shuttle to the moon. I won't deny it if asked. To summarize the problem: I am trying to

Wcf NHibernate Session management

六眼飞鱼酱① 提交于 2019-12-24 03:01:11
问题 I'm new to Castle, NHibernate and WCF. I implemented the session management for my MVC application based on the following article because it seemd to be the most advanced implementation of all posts I've read so far : http://nhibernate.info/blog/2011/03/02/effective-nhibernate-session-management-for-web-apps.html The only problem I got was that this uses some Asp.net specific functionality that isn't available in my WCF service like (HttpContext.Current.Items). I started to use WcfFacility

Override default Fluent NHibernate Column Mapping

白昼怎懂夜的黑 提交于 2019-12-24 02:25:06
问题 I am trying to find the syntax for changing the automap behavior of Fluent NHibernate. How would I modify the code below to map the UserId property to a column named UserIdentifier (as an example)? public class MyTypeMap : ClassMap<MyType> { public MyTypeMap() { Table("MyTypes"); Id(x => x.InstanceId).GeneratedBy.Guid().UnsavedValue(Guid.Empty); Map(x=> x.UserId); } } Thanks 回答1: public class MyTypeMap : ClassMap<MyType> { public MyTypeMap() { Table("MyTypes"); Id(x => x.InstanceId)