fluent-nhibernate

Fluent nhibernate automapping collection

巧了我就是萌 提交于 2019-12-04 15:30:17
I am trying to map my collections with FNHib automapping. The problems that I want to solve are: 1) I want all my collections in the project to be mapped via private field. How can I say that globally? 2) Is there any way to automap bidirectional relationship without explicitly overriding each of my entities. class OrganizationEntity example: private ISet<> _collectionWarehouse; public virtual IEnumerable<WarehouseEntity> CollectionWarehouse { get{return _collectionWarehouse; } set{_collectionWarehouse = new HashedSet<WarehouseEntity>((ICollection<WarehouseEntity>)value)} } Class

nhibernate - queryover - how to make dynamic sorting for joined queries

不问归期 提交于 2019-12-04 15:24:18
I have a user accounts table in admin panel and this table holds data from different db tables (tables in SQL database ). And user accounts table has to support paging and sorting. When I try to sort data with "FirstName" fetched from Account db table , .net throw an exception saying Location db table does not have "FirstName" column. My method is like: Account acc = null; //bunu bu şekilde tanımlamadan olmuyor :S AccountLogin accl = null; //bunu bu şekilde tanımlamadan olmuyor :S Program prog = null; Location school = null; Location town = null; Location city = null; //Takip edilen bloggerın

FluentNHibernate and Enums

半世苍凉 提交于 2019-12-04 15:10:49
问题 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

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

孤街浪徒 提交于 2019-12-04 14:36:58
问题 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

Fluent nhibernate + nhibernate.serach + lucene.net

ぃ、小莉子 提交于 2019-12-04 14:33:59
问题 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 回答1: Lucene.net is a self-contained search and directory utility. As far as I know it cannot be integrated with

bidirectional relationship patterns with nhibernate

人盡茶涼 提交于 2019-12-04 14:14:39
问题 In my domain, an Employee and a Department have a one-to-many bidirectional relationship; to let the child Employee synchronize this, I have an 'internal' access field for the Set (Iesi for NHibernate) of Employees that are in the Department, which would otherwise be readonly public. Like so: Department class: protected internal ISet<Employee> _staff; public virtual ReadOnlyCollection<Employee> Staff { get { return new List<Employee>(_staff).AsReadOnly(); } } public virtual void AddStaff

Fluent Nhibernate Enum Mapping

╄→尐↘猪︶ㄣ 提交于 2019-12-04 14:04:12
问题 I have some problem with enum mapping in fluent NHibernate. I know this question has been asked many times but I couldn't find any solution that worked for me. I'm newbie in NHibernate and it looks like I may have missed something simple and stupid. Here is my code. public class DBPublication { public virtual int pub_id { get; set; } public virtual PublicationStatuses status { get; set; } ... } public enum PublicationStatuses { on_moderation, active, ... } public class DBPublicationMap :

Nhibernate stores id=0 as null

和自甴很熟 提交于 2019-12-04 14:03:35
I have small problem with nHibernate (fluent) I have two objects, one contains another - a parent and a child (predefined objects, readonly). mappings: public class ParentClass { public virtual int Id { get; set; } public virtual ChildClass Metoda { get; set; } } public ParentClassMap() { Table("Wyceny"); Id(x => x.Id).Column("Id").GeneratedBy.TriggerIdentity(); References(x => x.Metoda).Column("RMW_ID"); } public ChildClass { public virtual int Id { get; set; } public virtual string Nazwa { get; set; } } public ChildClassMap() { Table("Metody"); Id(x => x.Id).Column("Id"); Map(x => x.Nazwa)

NHibernate and database changes/deployment

半城伤御伤魂 提交于 2019-12-04 14:00:04
问题 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 回答1: I have very good experience

Fluent NHibernate mapping on multiple non-PK fields

情到浓时终转凉″ 提交于 2019-12-04 13:51:52
问题 I have a situation similar to that described in Fluent NHibernate Mapping not on PK Field However, the relationship between my tables is described by multiple non-primary key columns. Imagine Chris Meek's situation but where a Person has a JobType and a Code that, together, should (sorry, it's a legacy database) uniquely describe a Person Person ------ Id PK JobType Code Name Order ----- Id PK Person_JobType Person_Code OrderDetails Serhat Özgel's answer describes using PropertyRef , but I