fluent-nhibernate

FluentNhibernate TypeLoadException

大城市里の小女人 提交于 2019-12-12 03:34:44
问题 I'm trying to build a sample MVC3 project using FluentNhibernate, and I'm getting a typeloadexception when I try to create a sessionFactory. SessionFactory //using System; //using NHibernate; //using NHibernate.Cfg; //using FluentNHibernate.Cfg; //using FluentNHibernate.Cfg.Db; //using System.Collections.Generic; //using System.Linq; //using System.Web; //using System.Web.Mvc; public class SessionProvider { public SessionProvider () { } public static ISessionFactory BuildFactory() { return

How to Fluently map with constraint in HasMany

痞子三分冷 提交于 2019-12-12 03:10:07
问题 I’m new to (fluent) nHibernate. I have 3 tables: Agency • AgencyId (pk) • AgencyAccountNo AgencyAccount • AgencyId (pk) (fk -> Agency. AgencyId) • AgencyAccountNo (pk) • ChainId (fk -> AgencyChain.ChainId) AgencyChain • ChainId (pk) AgencyAccount is effectively a versioning table. Everytime an Agency changes a new AgencyAccount row with an incremented AgencyAccountNo. I am trying to fluently map the relationships in Agency and AgencyChain so that only the Current AgencyAccount will be

NHibernate - Tries to update entity that does not need to be updated

拜拜、爱过 提交于 2019-12-12 02:49:13
问题 so I have an entity named Event which contains many Reports (one to many) which contains many sources (many to many). I'm facing a problem that I just cant figure out, when I'm trying to update my event, it will try to update the report because of the cascade (which is fine) and it will try to update the report's sources on the join table because of the cascade (which is fine), but for some reason it also tries to update the Source entity, which it shouldn't update because there is no change

Mapping Dictionary with entity based key using Fluent Nhibernate

↘锁芯ラ 提交于 2019-12-12 02:33:56
问题 I have the following NHibernate HBM that works as expected, but it makes my code brittle as the classes may change and I want to do the mapping in FNH, but try as I might, I cannot seem to get it to work, especially how you get the index-many-to-many: <map name="Permissions" table="PermissionsBySet" cascade="all"> <key column="PermissionSet_id" /> <index-many-to-many class="Picomole.ReadModel.Permission, Picomole.ReadModel" column="PermissionId" /> <element column="PermissionType" type=

Where clause not working with parantheses

▼魔方 西西 提交于 2019-12-12 02:27:09
问题 Suppose the following Query using a NH 3.4 and RepositoryPattern var list = _repository .QueryOver() .Where(x => (x.Age > 20)) // notice the parantheses .Future() .ToList(); Whith these parantheses added the NH is failing to work, and causes a SO exception. If replacing .Where(x => (x.Age > 20)) with .Where(x => x.Age > 20) it works as expected. Any clues on why it doesn't work with extra parantheses? Note This is a simplified scenario from the bigger picture. In production i'm passing that

FluentNHibernate: Just another Mapping Question

送分小仙女□ 提交于 2019-12-12 02:15:21
问题 Which convention should be used to alter column name of CompositeId().KeyReference(x=>x.Key,/*THIS PART*/) method? I have used all available conventions in FluentNHibernate.Conventions and still haven't found the answer. Thanks in advance 回答1: still not possible now (FNH 1.2), except with some reflection-magic class CompositeKeyConvention : ICompositeIdentityConvention { public void Apply(ICompositeIdentityInstance instance) { var columninspector = instance.KeyManyToOnes.First(k => k.Name ==

Fluent NHibernate index-many-to-many

断了今生、忘了曾经 提交于 2019-12-12 01:54:19
问题 Is there currently a way to use the equivalent of the index-many-to-many NHibernate tag in Fluent NHibernate? The mapping I am trying to achieve was generated almost perfectly using AsMap on a HasManyToMany , apart from this one element specifying the index in the map: Generated was: <index type=... Should have been: <index-many-to-many class=... EDIT: Currently the workaround I am using is to generate the partially incorrect mapping, manually editing the mapping file, commenting out the

Fluent Nhibernate mapping related items

北城以北 提交于 2019-12-12 01:35:53
问题 I am trying to relate 2 items. I have a table that is simply an Id field, and then 2 columns for the Item Id's to relate. I want it to be a 2 way relationship - that is, if the items appear twice in the table, I only want one relationship connection back. So, here's my item: public class Item { public virtual Guid ItemId {get; set;} public virtual string Name {get; set;} public virtual IList<Item> RelatedItems {get; set;} } The table for relating the items looks like this: CREATE TABLE

Fluent NHibernate one-to-one mapping with synthetic keys

一个人想着一个人 提交于 2019-12-12 01:35:48
问题 I have two tables tblPart ( partId, subpartId UNIQUE NULL ) tblSubpart ( subpartId ) So I can only have zero or one subPart associated with the part at the same time. I'm trying to map this as ClassMap<Part> { HasOne(x=>x.Subpart); } and the convention rewrites the foreign key so it uses subpartId instead of partId. however generated query ads subpart.partId into the query, which does not exist. What am I doing wrong here? 回答1: Why not use inheritance? Check out this question Inheritance

Is there a better implementation for SybaseDialect in Version 3.0 of NHibernate?

给你一囗甜甜゛ 提交于 2019-12-12 01:34:45
问题 We have upgraded to NHibernate 3.0 with Fluent-NHibernate. In version 2.1.2 we where able to use the SybaseDialect for ASE 12. In version 3.0 SybaseDialect for ASE 12 is not supported. I reused the old Dialect from Nhib 2.1.2 and all is working. What I wanted to ask since this one was removed as it was considered not a good implementation, is there a better one out there? Since it's working I am not sure what improvements need be made but I thought I would ask. 回答1: This blog post has the