fluent-nhibernate

Fluent Nhibernate problem (ClassMap)

烈酒焚心 提交于 2019-12-03 10:19:49
问题 I have the following XML (.hbm): <property name="Geometry" column="the_geom"> <type name="NHibernate.Spatial.Type.GeometryType,NHibernate.Spatial"> <param name="subtype">MULTIPOLYGON</param> <param name="srid">-1</param> </type> </property> It´s using Nhibernate Spatial type... How can I map that property using ClassMap (Fluent Nhibernate) ? Thanks 回答1: Well, I've not used NHibernate Spatial, but I browsed through the code and it looks like GeometryType inherits from IUserType so you should

Fluent NHibernate: How to Map M:N many-to-many with composite keys on both sides

99封情书 提交于 2019-12-03 10:13:41
OK, so here is the problem. Its not even as crazy as the guy who wants to map m:n with different column counts in his PKs. No matter what I do or where I look there seems to be no method chain that will result in a successful mapping of this. I have tried doubling up on the Parent and Child columns, eg ParentColumn("").ParentColumn("").ChildColumn("").ChildColumn("") - didnt' think it would work and I was right. Tried just using ForeignKeyConstraintNames no luck. Still FNH is mapping one side to a single key. public partial class M2M2ParentAMap : ClassMap<M2M2ParentA> { public M2M2ParentAMap()

nhibernate not saving foreign key Id

核能气质少年 提交于 2019-12-03 10:08:48
问题 I have a simple model I'm attempting to persist using fluent-nhibernate: public class Person { public int Id { get; set; } public string Name { get; set; } public IList<Address> Addresses { get; set; } } public class Address { public int Id { get; set; } public int PersonId { get; set; } public string Street { get; set; } } Some sample data: var person = new Person() {Name = "Name1", Addresses = new[] { new Address { Street = "Street1"}, new Address { Street = "Street2"} }}; When I call

NHibernate - not-null property reference a null or transient value

夙愿已清 提交于 2019-12-03 09:35:51
I'm getting this exception (Full exception at the bottom): NHibernate.PropertyValueException was unhandled by user code Message="not-null property references a null or transient valueClearwave.Models.Encounters.Insurance.Patient" Source="NHibernate" EntityName="Clearwave.Models.Encounters.Insurance" PropertyName="Patient" I've done a lot of Googling and it seems the most common cause for that error is when an association is bi-directional but only one half has been set. As in: Insurance.Patient = Patient is called but Patient.Insurances.Add(Insurance) is not. I do, in fact, have a scenario

Fluent NHibernate generates extra columns

别来无恙 提交于 2019-12-03 09:25:27
问题 We are using Fluent NHibernate for data object model in the company i work. A couple of days ago, we encountered an issue that Fluent NHibernate generates an extra column which does exist neither in model nor in mapping. Here is the situation: My Model: FirstClass.cs public class FirstClass { public virtual int Id { get; private set; } public virtual SecondClass MyReference { get; set; } public virtual DateTime DecisionDate { get; set; } } My Mapping: public class FirstClassMap : ClassMap

Fluent nhibernate + nhibernate.serach + lucene.net

寵の児 提交于 2019-12-03 09:05:35
can someone tell me how to use nhibernate serach and lucene with fluent nhibernate. I have my application writen with fluent nhibernate but now i need full text serach but do not know how to implmenet nhibernate search with lucene to fluent nhibernate. i found this but it is not much and do not know how to use it: Fluent NHibernate + Lucene Search (NHibernate.Search) thx in advanced Lucene.net is a self-contained search and directory utility. As far as I know it cannot be integrated with nhibernate by mappings only. You should implement adding data to lucene index by yourself. Lucene allows to

The 'Permanent' SessionFactory, ASP.NET MVC and nHibernate

不羁岁月 提交于 2019-12-03 08:56:54
I've been building an application with Fluent nHibernate/ASP.NET MVC - and I've dug around and figured out that it's considered most appropriate practice to keep a 'permanent' SessionFactory open, and then use sessions for each request to the database. Okay, this sounds good... I'm quite confused on how to accomplish this, though. Everything I find assumes an entire structured framework that uses some kind of IoC container system ...and that's just too advanced for what I have so far. Are there any more simple examples of how to implement this kind of design? I've taken a look at Where can I

FluentNHibernate and Enums

爱⌒轻易说出口 提交于 2019-12-03 08:51:11
I have an enum called Permissions. A user can be assigned permissions, or permissions can be asigned to a role and the user can be given a role. User and Role both have a property like this: public virtual IList<Permission> Permissions { get; set; } I want to use an enum for Permissions so in my code I can do things like public static bool UserHasPermission(Permission.DeleteUser) Right now I have about 50 different permissions in my enum. It would be nice if I didn't have to populate a mirror set of data in the database. My enum looks like this: public enum Permission { //site permissions 1-99

NHibernate and database changes/deployment

蹲街弑〆低调 提交于 2019-12-03 08:44:34
I'm looking into using NHibernate and Fluent NHibernate for my next project but one thing I'd like clearing up before hand is how do you manage changes to the database? eg, I have NH + FNH working, application has been deployed and is live but we make a change in the development environment, for example say we add a new property to a entity which is mapped using NH/FNH. How do you apply that change to the database without having to drop the table? Thank you GE I have very good experience using this framework: http://code.google.com/p/migratordotnet/ Basically you create a class for each

Mapping interface or abstract class component

大兔子大兔子 提交于 2019-12-03 08:27:06
Please consider the following simple use case: public class Foo { public virtual int Id { get; protected set; } public virtual IBar Bar { get; set; } } public interface IBar { string Text { get; set; } } public class Bar : IBar { public virtual string Text { get; set; } } And the fluent-nhibernate map class: public class FooMap : ClassMap<Foo> { public FooMap() { Id(x => x.Id); Component(x => x.Bar, m => { m.Map(x => x.Text); }); } } While running any query with configuration, I get the following exception: NHibernate.InstantiationException : "Cannot instantiate abstract class or interface: