fluent-nhibernate

multithreading with fluent nhibernate

余生颓废 提交于 2019-12-10 12:14:34
问题 private ISessionFactory GetSessionFactory(string sessionFactoryConfigPath) { GetFullSessionFactoryFor(sessionFactoryConfigPath); while (!sessionFactoryReady) Thread.Sleep(1000); return (ISessionFactory)sessionFactories[sessionFactoryConfigPath]; } private void GetFullSessionFactory(string sessionFactoryConfigPath) { ThreadPool.QueueUserWorkItem(state => { ISessionFactory sessionFactory=null; FluentConfiguration fluentConfiguration = fluentConfiguration.ExposeConfiguration(c => c.SetProperty(

Configuring Fluent NHibernate and NHibernate Validator

安稳与你 提交于 2019-12-10 12:13:51
问题 I am struggling to get Fluent NHibernate and the NHibernate Validator working together and there seems to be a lack of documentation on the internet about the best way to do this. I have found a few websites which detail how to configure the validator and NHibernate but not Fluent NHibernate. I realise that Fluent NHibernate is just NHibernate with nice mappings but I can't quite get my head around the configuration. This is the code that I use to setup my SessionFactory : public static void

Fluent Nhibernate HasMany mapping issue

你说的曾经没有我的故事 提交于 2019-12-10 11:44:13
问题 I'm new to Fluent and NHibernate and I'm not sure how to map this specific relationship that exists in my database. I have the following ER diagram below that outlines my table structure. Below are my current C# entity classes: public class GroupHeader { public virtual Guid Id { get; private set;} public virtual string Name { get; set; } public virtual string Description { get; set; } public virtual IList<RightHeader> Rights { get; set; } public virtual IList<GroupRight> GroupRights { get;

Delete an item from many-to-many relationship

半城伤御伤魂 提交于 2019-12-10 11:32:45
问题 I've following mapping for two tables having a Many-to-Many relationship between them. How do I delete an entry from the mapping table, which is 'TB_EMAIL_GRUPO_ARQUIVO' in my case? I just need to delete the data from this "joining" table and I don´t need to delete it from the "parent tables". GrupoModulo public GrupoModuloMap() { Schema(Const.SCHEMA); Table(Const.TB_EMAIL_GRUPO_MODULO); CompositeId() .KeyReference(x => x.Grupo, Const.ID_GRUPO) .KeyReference(x => x.Modulo, Const.ID_MODULO);

SqlDateTime overflow using NHibernate

◇◆丶佛笑我妖孽 提交于 2019-12-10 11:22:57
问题 I persist my objects using NHibernate in the database the App object have a property defined: public virtual DateTime ReleaseDate { get; set; } in the mappingClass: Map(x => x.ReleaseDate).Not.Nullable(); which in the sqlServer 2008 its dataType is dateTime and is not nullable. for the first Time it saves to database with no error. but after updating app info I encounter SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. but the app release date is a valid

Fluent Nhibernate AutoMapping Inheritance and Ignoring an Abstract Property

若如初见. 提交于 2019-12-10 11:19:51
问题 I have an inheritance structure that i have succesfully mapped Product (base) PdfProduct (inherits from Product) & OtherProduct(inherits from Product) These are working fine and i have done a simmilar thing before with hmb.xml files. In the previous project i had a problem when i was trying to find out what type the product was but i couldnt do it as it was a Proxy (product is PdfProdcut). To solve this, i added an abstract property to the base Product and overrided it in the other classes

Map One-To-One Relationship Doesn't Allow Inserting

烂漫一生 提交于 2019-12-10 10:48:09
问题 I'm trying to setup a one-to-one mapping from my Users to the UserDetails table. Say I have the following tables in my database: Users: - UserID (PK, Identity) - UserName - Password UsersDetails: - UserID (PK, FK) - FirstName - LastName I have created the following poco classes: public class User { public virtual int UserID { get; set; } public virtual string UserName { get; set; } public virtual string Password { get; set; } public virtual UserDetails Details { get; set; } } public class

NHibernate Save Is Trying to Clear Child KeyColumn Id On Update

对着背影说爱祢 提交于 2019-12-10 10:34:18
问题 I am trying to create a parent object that has multiple children in a 1 to many relationship. I am not referencing the Parent object on the child object, instead I am mapping its keycolumn as a field. When I try to save this object for the first time, it works as expected without any issues (cascading all the Id's and children). When I try to get the object from the database, update some properties on it and re-save it again, it fails. The actual error message I am getting is "Could not

nhibernate fluent bool to smallint mapping

☆樱花仙子☆ 提交于 2019-12-10 10:26:43
问题 In my application I have a bool property named DisplayIndicator. In the database (DB2) it's correspondence is DISPL_IND column of type smallint. The correspondence is the following: [DisplayINdicator=True, DISPL_IND=1] and [DisplayINdicator=False, DISPL_IND=0] Is it possible to map using nhibernate fluence the bool property to smallint? 回答1: I figured it out, after Frans's advise. I created a class that represents nhibernate user type used to map boolean type to short type: public class

NHibernate two columns as composite key AND foreign keys at the same time

人盡茶涼 提交于 2019-12-10 10:26:34
问题 First of all, I've searched thoroughly online and here, without finding a clear solution to the task at hand. My apologies if my search wasn't accurate enough and this answer has already been posted. The issue: I have a table. This table must have a primary key on two fields, and other fields containing some data. The two fields that are primary key must also be foreign keys, each on a different table. Something like (pseudo code ahead): Product: Id (pk) Category: Id (pk) ProductCategory: