fluent-nhibernate

How can I make composite key enums use int in fluent nhibernate with a convention?

不羁岁月 提交于 2019-12-14 02:25:31
问题 I have a composite key entity where one property is an int, and the other is an enum. The enum is currently mapping by string, but it needs to be int. I have an IUserTypeConvention that already does this, but it doesn't work for composite keys. I have an Accept() method that correctly locates composite keys with enums in it, but I cannot figure out the Apply() code. public class CompositeKeyEnumConvention : ICompositeIdentityConvention, ICompositeIdentityConventionAcceptance { public void

Error with Nhibernate: System.Data.SqlClient.SqlException: Incorrect syntax near 'Index'

怎甘沉沦 提交于 2019-12-14 00:47:53
问题 i have an nhibernate solution and i'm trying to do a save, but i'm getting this error: Test method HelloMusic.Core.Test.CrudTests.TestTrackAdd threw exception: NHibernate.Exceptions.GenericADOException: could not insert collection: [HelloMusic.BLL.Track.Credits#20][SQL: INSERT INTO Tracks_Credits (TrackID, Index, CreditID) VALUES (@p0, @p1, @p2)] ---> System.Data.SqlClient.SqlException: Incorrect syntax near 'Index'. If this is intended as a part of a table hint, A WITH keyword and

What's the most productive way to do NHibernate mapping?

巧了我就是萌 提交于 2019-12-13 18:07:46
问题 I know annotations to do the hibernate mapping in Java and am looking now for a similar way to do the same in C# and NHibernate. I found out that there exists several approaches do the mapping in xml files NHibernate.Mapping.Attributes (NHMA) Fluent are there any more?? I tried NHMA and found out it had some blocking points for me... I don't want you to discuss, whats the best way to map models to NHibernate, but I was looking for a good comparison on the internet. Do you know such sites?

FluentNHibernate AutoPersistenceModel with Interface references

别等时光非礼了梦想. 提交于 2019-12-13 17:41:25
问题 I am trying out the FluentNHibernate AutoPersistenceModel for the first time. It was very simple to get a basic example working but I am having a problem making it fit with how I work. I normally work to interfaces so that my entities all implement an interface and reference all related entities by their interface, not their concrete type. Given the following classes: public Interface IFoo { } public Interface IBar { IFoo Foo { get; set; } } public Class Foo : IFoo { } public Class Bar : IBar

Configuring Fluent NHibernate from NHibernate config section

二次信任 提交于 2019-12-13 17:08:28
问题 I'm trying to use Fluent NHibernate in my solution by configuring it with the following NHibernate xml configuration section <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > <session-factory name="mitre"> <property name="dialect">NHibernate.Dialect.Oracle9iDialect</property> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property> <property name

Fluent NHibernate QueryOver to select items not in another table (left join)

偶尔善良 提交于 2019-12-13 16:10:46
问题 I have two tables: all: id | propA | propB | someOtherColumn hidden: id | propA | propB and corresponding classes (Mapped, no relationship mapped yet) I would like to get all rows from first table, minus any results which match by propA or propB property. I managed to do it by Criteria API but would like to see how it is done with QueryOver API, if possible without subqueries but with a left excluding join. Criteria version: var dc1 = DetachedCriteria.For<hidden>() .Add(Restrictions.IsNotNull

Fluent NHibernate - Mapping entities from multiple assemblies

回眸只為那壹抹淺笑 提交于 2019-12-13 14:07:16
问题 Is it possible to map entities from multiple assemblies in Fluent NHibernate? I tried AutoPersistenceModel .MapEntitiesFromAssemblyOf<Class1>() .AddEntityAssembly(assembly) But it only loads entities from 'assembly' and not from parent assembly of Class1. EDIT. I figured it out. I had to update Fluent NHibernate to version 1.0, where you can do it like this: AutoMap .AssemblyOf<Class1>() .AddEntityAssembly(typeof(UserEntity).Assembly) 回答1: I figured it out. I had to update Fluent NHibernate

DB Column named “Order” with Fluent NHibernate

戏子无情 提交于 2019-12-13 13:15:21
问题 I discovered that one of the tables of a legacy db I'm working on has a colum named "Order". Unfortunately I cannot change the DB structure. My Fluent NHibernate class looks like public class SiteMap : AutoMap<Site> { public SiteMap() { WithTable("Sites"); Id(x => x.ID, "Id") .WithUnsavedValue(0) .GeneratedBy.Identity(); Map(x => x.Name, "Name"); //various columns mapping and then... Map(x => x.SiteOrder, "Order"); } } I do not know if the problems is FluentNH or NHibernate itself but I can

NHibernate.AssertionFailure: null identifier

半腔热情 提交于 2019-12-13 13:15:13
问题 Before I kick my computer in to next week... I've checked out every other question about this, but none of them have the solution. I've stripped this code right back, but it's still not working. I'm getting this error when saving an object: NHibernate.AssertionFailure: null identifier This is my mapping file: public class OrderMap : BaseMap<Order> { public SalesOrderMap() { Id(x => x.Id).Column("OrderId"); } } This is the entity: public class Order { public virtual int Id { get; protected set

Is Fluent NHibernate ready for production code now?

倾然丶 夕夏残阳落幕 提交于 2019-12-13 09:49:34
问题 The subject of this question speaks for itself. I am wondering if Fluent NHibernate is ready for production code. I am especially wondering in light of some seemingly simple problems that I am having with it that I haven't yet found fully satisfactory solutions for (and the community doesn't have a solution for?) Why is Fluent NHibernate ignoring my convention? Why is Fluent NHibernate ignorning my unique constraint on a component? Yes, I am aware of this old question which is more than a