fluent-nhibernate

Fluent NHibernate - how to create table-per-subclass mapping using a discriminator?

守給你的承諾、 提交于 2019-12-11 01:56:25
问题 I've looked at a lot of questions on SO and google regarding sub-class mappings in nhibernate / fluent-nhibernate and not managed to find anyone with the same problem as me. I've followed the basic instructions from the fluent-nhibernate wiki (http://wiki.fluentnhibernate.org/Fluent_mapping#Subclasses) but this hasn't helped. I have a base entity called Operation - which has a base table associated with it, I then have sub-tables UnpaidCheque, Refund etc - the primary key for each of these

NHibernate.QueryException: could not resolve property

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 01:49:09
问题 I'm using FluentNHibernate and Linq To Nhibernate, with these entities (only the relevant parts): public class Player : BaseEntity<Player> { private readonly IList<PlayerInTeam> allTeams = new List<PlayerInTeam>(); public IEnumerable<Team> Teams { get { return from playerInTeam in allTeams where playerInTeam.Roster.Match == null select playerInTeam.Roster.Team; } } } public class PlayerInTeam : BaseEntity<PlayerInTeam> { public int PlayerNumber { get; set; } public Player Player { get; set; }

S#arp Architecture many-to-many mapping overrides not working

巧了我就是萌 提交于 2019-12-11 01:48:06
问题 I have tried pretty much everything to get M:M mappings working in S#arp Architecture. Unfortunately the Northwind example project does not have a M:M override. All worked fine in my project before converting to S#arp and its choice of Fluent NHibernate's Auto mapping. I like the auto-mapping, it's good, however the overrides do not seem to register. It all seems to work in memory and in tests, however when committing data to a database nothing gets inserted into my M:M reference table. If we

NHibernate use Firebird own generator

≯℡__Kan透↙ 提交于 2019-12-11 01:47:12
问题 Having own generator in Firebird DB called GEN_PATIENT_ID I would like to leave the generation of ID on the DB side instead of NHibernate and FluentNHibernate. Following this link I am overriding the default Fluent behavior like this: public class PatientOverride : IAutoMappingOverride<Patient> { public void Override(AutoMapping<Patient> mapping) { mapping.Cache.ReadOnly().Region("LongTermReadWrite"); mapping.Id(x => x.Id).GeneratedBy.Sequence("GEN_PATIENT_ID"); mapping.HasOne(patient =>

Fluent nhibernate One-to-Many when Inverse is used Child table's Foreign key is null

放肆的年华 提交于 2019-12-11 00:55:22
问题 I have a parent and child table and entites are created and mapped using one to many relation ship. On one to many side when i use Inverse() then the child table's foreign key value is inserted as null. public class TableA { public virtual long ID { get; set; } public virtual string Name { get; set; } public virtual IList<TableB> TableB { get; set; } } public class TableB { public virtual long ID { get; set; } public virtual string Name { get; set; } public virtual TableA TableA { get; set; }

how to Unit test fluent mappings, with in memory sqlite when you got sequences

心不动则不痛 提交于 2019-12-11 00:23:40
问题 My Real db is oracle, and has sequences(not under my control). I wanna test the mappings with in memory sqlite db, I thought about a few options, do a sequence conventions(if possible) that will be active only when I'm on oracle, make the Id Mapping call another method that will resolve the id mapping by it self and ask some one about the configured db. What is the best practice for my problem? 回答1: Use the GenretedBy.Native([seqName]); 来源: https://stackoverflow.com/questions/4885231/how-to

AutoMapping Custom Collections with FluentNHibernate

瘦欲@ 提交于 2019-12-11 00:09:31
问题 I am retrofitting a very large application to use NHibernate as it's data access strategy. Everything is going well with AutoMapping. Luckily when the domain layer was built, we used a code generator. The main issue that I am running into now is that every collection is hidden behind a custom class that derives from List<>. For example public class League { public OwnerList owners {get;set;} } public class OwnerList : AppList<Owner> { } public class AppList<T> : List<T> { } What kind of

How to map Type with Nhibernate (and Fluent NHibernate)

蹲街弑〆低调 提交于 2019-12-11 00:05:02
问题 Let's say I have something similar to this : public class DataType { //For NHibernate private DataType(){} public DataType(string name, Type type, string defaultValue) { Name = name; TypeOfContent = type; DefaultInvariantStringValue = defaultValue; } public string Name { get; set; } public Type TypeOfContent { get; set; } public string DefaultInvariantStringValue { get; set; } } How do I map the property TypeOfContent with NHibernate (fluent mapping would be appreciated too)? I would

NHibernate query cache not working after update to the database

北城以北 提交于 2019-12-10 23:57:41
问题 I have enabled 2nd level cache in FluentNHibernate: Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005 .ConnectionString(connectionString) .Cache(c => c.ProviderClass<SysCacheProvider>().UseQueryCache()) ) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<PersonMap>()); My mapping is as follows: public PersonMap() { Id(x => x.Id); Map(x => x.Name); Cache.ReadWrite(); } When I call Persons from my repository, I run: var query = session.GetSession().CreateCriteria<Person>("p") .Add

Backing field for collection is null when using LinFu ProxyFactoryFactory in NHibernate

十年热恋 提交于 2019-12-10 23:40:11
问题 I am having a problem when I try switching from the Castle ProxyFactoryFactory to the LinFu ProxyFactoryFactory in NHibernate. I have an entity like this: public class Foo { private ISet<Bar> _bars = new HashedSet<Bar>(); public virtual void AddBar(Bar bar) { if (!_bars.Contains(bar) _bars.Add(bar); bar.Foo = this; } } This is mapped with Fluent NHibernate like this: public class FooDbMap : ClassMap<Foo> { public FooDbMap() { HasMany(x => x.Bars) .Access.CamelCaseField(Prefix.Underscore)