fluent-nhibernate

Mapping nhibernate custom types with parameters using Fluent Nhibernate

与世无争的帅哥 提交于 2019-12-05 12:38:41
I have an nhibernate custom type that I would like to map with Fluent NHibernate. The HBM mapping looks like this. <property name="DateConvention" access="nosetter.camelcase-underscore" column="date_convention" not-null="true"> <type name="DataAccess.Types.DateConventionCustomType, Services.DataAccess"> <param name="type">Services.Data.DateConventionTypeParameter, Services.Data</param> </type> </property> I have successfully mapped the custom type, but I cannot find a way to configure the parameters on the custom type mapping. Is there a way to map this using fluent nhibernate ? Fluent

Is it possible to use (fluent)nhibernate with an odbc connection?

♀尐吖头ヾ 提交于 2019-12-05 12:30:10
i have to use a custom odbc driver. All i need to pass as a connection string is the DSN. How do i do this with (fluent)nhibernate? FluentNHibernate.Cfg.Db does only offer a OdbcConnectionStringBuilder class with an DSN method. How do i use this? You can create your own OdbcConfiguration class that derives from PersistenceConfiguration . Depending on your database, you will have to replace the Dialect in the following class. public class OdbcConfiguration : PersistenceConfiguration<OdbcConfiguration, FluentNHibernate.Cfg.Db.OdbcConnectionStringBuilder> { protected OdbcConfiguration() { Driver

Foreign Keys with SchemaExport in Fluent NHibernate using SQLite

会有一股神秘感。 提交于 2019-12-05 12:00:32
I am attempting to create a simple database application which keeps track of loans of various types of equipment using Fluent NHibernate and SQLite. However, when I try to generate the database structure with SchemaExport for use in unit testing, foreign keys for one-to-many relationships aren't created. Here is my Equipment entity: public virtual int Id { get; set; } public virtual EquipmentType Type { get; set; } public virtual int StockId { get; set; } And here are my mappings for Equipment : Id(x => x.Id); References(x => x.Type); Map(x => x.StockId); The SQL is generated correctly, except

Mapping a read-only property with no setter using Fluent NHibernate

人走茶凉 提交于 2019-12-05 11:41:13
I have a domain class that looks like this. I want NHibernate to save the current value of LastUpdate when inserting/updating so that I can use it in queries, but to ignore it when retrieving a Foo from the database and let the object itself recalculate the value when I actually access it. public class Foo { public DateTime LastUpdate { get { /* Complex logic to determine last update by inspecting History */ return value; } } public IEnumerable<History> History { get; set; } /* etc. */ } My mapping for Foo looks like this: public class FooMap : ClassMap<Foo> { Map(x => x.LastUpdate) .ReadOnly(

How to set the timeout on a NHibernate transaction

谁都会走 提交于 2019-12-05 11:31:46
I need a lot of DB processing done in a single transaction, including some processing using NHibernate. To make everything work in the same transaction, I'm using NHibernate's Session to start it, and enlist the the commands for the other work in it. Everything goes OK until I commit. At that time I get a transaction timeout. How can I set the NHibernate transaction timeout value sufficiently high? We use FluentNHibernate. After some trial and lots of error I found this: It appears that NHibernate takes the "TransactionManager.DefaultTimeout" value. It can be set via <system.transactions>

working with Fluent NHibernate and guid ids

吃可爱长大的小学妹 提交于 2019-12-05 11:30:33
We're working with Fluent NHibernate 1.2 and our primary key is a guid saved in a nvarchar(32) column, working with Oracle 11gr2. How can we make this work? (making an automatic conversion...) Thanks ahead, random programmer... UPDATE: forgot to mention, the guid is saved WITHOUT dashes ... Update: You will have to implement your own IUserType to handle the dashless Guids. You can read about it here: http://dotnet.dzone.com/articles/understanding-nhibernate-type The detail below is now irrelevant to the question but I'll keep it here for future reference for people to find. Using Guids

Fluent NHibernate AutoMapping with discriminator

早过忘川 提交于 2019-12-05 10:26:21
I'm trying to map inheritance with discriminator, but subclasses don't have discriminator value. How to solve it using AutoMappings? Domain objects are as following: public abstract class Item : GuidIdentityEntity { public virtual string Name { get; set; } } public class Product : Item {} public class RawMaterial : Item {} Configuration looks like: AssemblyOf<Item>() .IgnoreBase<GuidIdentityEntity>(); .IncludeBase<Item>(); .Setup(setup => { setup.DiscriminatorColumn = type => "Discriminator"; setup.IsDiscriminated = type => type == typeof(Item); setup.SubclassStrategy = type => (type == typeof

Why is Fluent NHibernate ignoring my unique constraint on a component?

自古美人都是妖i 提交于 2019-12-05 10:11:55
In my map I have: Component( x => x.ExposureKey, m => { m.Map(x => x.AsOfDate).Not.Nullable(); m.Map(x => x.ExposureId).Length(30).Not.Nullable(); } ).Unique(); The relevant output from the HBM is <component name="ExposureKey" insert="true" update="true" optimistic-lock="true" class="Some.Namespace.CreditExposureKey, Some.Namespace, Version=0.0.0.0, Culture=neutral, PublicKeyToken=aaaaaaaaaaaaaaaa"> <property name="AsOfDate" type="System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="AsOfDate" not-null="true"/> </property> <property name=

Fluent NHibernate Visual Designer [closed]

蓝咒 提交于 2019-12-05 09:32:28
Is there a visual designer similar to Mindscape's NHibernate designer for Fluent NHibernate? I have decided to move from EF4 to NH3, but without a visual design interface it is going to be a hard sell to my team who are used to the EF4 model creation interface. I've only heard of Mindscape's NHibernate Designer and Visual NHibernate . It looks like the latter provides support for Fluent NHibernate mappings. Mindscape NHibernate Designer does not currently support generating Fluent NH mappings, that is correct. John-Daniel (Co-founder, Mindscape) Devart Entity Developer for NHibernate provides

Fluent nHibernate no identity column in table

China☆狼群 提交于 2019-12-05 08:45:10
How do I specify with fluent NHibernate mapping for a table that doesn't have an identity column? I want something like this: public sealed class CustomerNewMap : ClassMap<CustomerNew>, IMap { public CustomerNewMap() { WithTable("customers_NEW"); Not.LazyLoad(); Not.Id(); // this is invalid... Map(x => x.Username); Map(x => x.Company); } } I mean no primary key defined in the database (not much defined in the database). AwkwardCoder I found the answer to be: public CustomerNewMap() { WithTable("customers_NEW"); Not.LazyLoad(); Id(x => x.Username).GeneratedBy.Assigned(); Map(x => x.Company); }