fluent-nhibernate

Finding the Primary Key from a ClassMap<T>

前提是你 提交于 2019-12-31 03:56:29
问题 With Fluent NHibernate , I have an arbitrary ClassMap<T> , I want to be able to find out what property (if any) was set as the primary key . Example: public class PersonMap : ClassMap<Person> { public PersonMap() { Id(p => p.StupidPrimaryKeyId).GeneratedBy.Identity().Column("StupidPrimaryKeyId"); } } ... //usage MemberInfo primaryKeyMember = FindPrimaryKey(new PersonMap()); Can anybody tell me what the method body for FindPrimaryKey would have to be in order to return StupidPrimaryKeyId ?

How to change default FlushMode to Commit in C#?

北慕城南 提交于 2019-12-31 03:18:14
问题 So... already said it: How to change FlushMode to Commit in C#? I mean, In Fluent NHibernate FlushMode by default is setted as Auto. So... to set FluentMode to Commit , I need to open session and then change It: var someSessionFactory = ... bla bla ..; var session = someSessionFactory.OpenSession(); session.FlushMode = FlushMode.Commit; This will work but... this will mean that I need to call method which contains FlushMode.Commit each time I am opening session. To inicialize sessionFactory I

FluentNHibernate query on many-to-many relationship objects

妖精的绣舞 提交于 2019-12-31 02:20:09
问题 For some reason i can't get this query right, and i can't understand why... I have an object called 'Blog' that has an Id, and a list of 'Tag's. Each 'Tag' has an id and a 'Name' property. Since this is a many to many relationship, I have another table called 'blog_tags' connecting them. The mappings look like this : public class BlogsMapping : ClassMap<Blog> { Table("blogs"); Id(x => x.Id).GeneratedBy.Identity(); Map(x => x.Content); HasManyToMany(x => x.Tags) .Table("Blog_Tags")

How to map composite-id with fluent nhibernate using an interface?

安稳与你 提交于 2019-12-31 02:08:08
问题 I'm trying to switch out .hbm mappings to fluent mappings and have a problem with the mapping of composite-ids and the usage of Interfaces the Class looks as follows: public class ClassWithCompositeId { public virtual IKeyOne KeyOne { get; set; } public virtual IKeyTwo KeyTwo { get; set; } } our hbm mapping looks like this: <hibernate-mapping ...> <class name="ClassWithCompositeId" table="t_classwithcompositeid"> <composite-id> <key-many-to-one name="KeyOne" column="colkeyone" class="company

Getting Fluent NHibernate To Build Database tables

心不动则不痛 提交于 2019-12-30 14:42:15
问题 I am building an app with ASP.NET MVC2, Fluent NHibernate, StructureMap, and PostgreSQL. I am a total newbie when it comes to Fluent NHibernate. I got a setup going from a couple different sources but when I build and run my app it doesnt create the database tables for the database in my connection string. I have code in a few different files so Im not sure which code I need to post of if I should post all of it. If there is one key to check for please let me know or let me know to post all

Getting Fluent NHibernate To Build Database tables

血红的双手。 提交于 2019-12-30 14:41:01
问题 I am building an app with ASP.NET MVC2, Fluent NHibernate, StructureMap, and PostgreSQL. I am a total newbie when it comes to Fluent NHibernate. I got a setup going from a couple different sources but when I build and run my app it doesnt create the database tables for the database in my connection string. I have code in a few different files so Im not sure which code I need to post of if I should post all of it. If there is one key to check for please let me know or let me know to post all

One to Many mapping with an intermediate table

本小妞迷上赌 提交于 2019-12-30 11:34:06
问题 I thought I had this one pegged by mapping the intermediary table as a HasMany and between intermediary and child as HasOne, however HasOne expects to share a key. (No Inverse option.:[ ) Anyhow, the relational structure I have: Address (Child) AddressId ..Address Fields AddressCustomer (Intermediary) AddressCustomerId AddressId CustomerId Customer (Parent) CustomerId ..Customer Fields Why I have this intermediary table instead of a normal 1-many? Because there will be other entities that

NHibernate 2 + Fluent Nhibernate medium trust

妖精的绣舞 提交于 2019-12-30 11:05:38
问题 Will NHibernate 2 and\or Fluent Nhibernate work in a medium trust environment. If not are there any work-arounds? 回答1: Not sure about fluent NH - I assume it should - it just translates to XML. With NH itself you will loose bytecode optimization, all your setters/constructors will need to be public. If you need to use lazy loading you will have to have your proxies generated with build (NH proxy generator). Should you have some permissions enabled in your medium trust settings you can relax

nhibernate query all objects implementing an interface

大兔子大兔子 提交于 2019-12-30 10:34:56
问题 For example, if you have an Apple : IWhatever, and an Orange : IWhatever and you want to find both of them because they are IWhatevers, what do you need to do in NHibernate? Is it completely dependent on the HQL or criteria query, or is there something you must do in the mapping also? If there is a mapping requirement, can Fluent NHibernatee support it? 回答1: You could do a UnionSubClass mapping. Unforntunately it is unsuported in Fluent. You mapping would be something like: <class name=

nhibernate query all objects implementing an interface

最后都变了- 提交于 2019-12-30 10:34:19
问题 For example, if you have an Apple : IWhatever, and an Orange : IWhatever and you want to find both of them because they are IWhatevers, what do you need to do in NHibernate? Is it completely dependent on the HQL or criteria query, or is there something you must do in the mapping also? If there is a mapping requirement, can Fluent NHibernatee support it? 回答1: You could do a UnionSubClass mapping. Unforntunately it is unsuported in Fluent. You mapping would be something like: <class name=