fluent-nhibernate

NHibernate paging criteria with fetchmode eager. (using fluent NH)

烈酒焚心 提交于 2019-12-04 21:18:19
Question: How to get an eager loaded criteria to return paged results on the root entity with all child collections set fetchmode = eager. I am trying to get a 10 item paged result set with eager loaded child collections. The problem is the query does a select top 10 wrapped around the entire select. The causes it to return only the first 10 results including all joined records. If the first entity has 10 child objects then my result set will return 1 entity with 10 child objects loaded. I need the entities and child collections returned hydrated (lazy off). If I turn lazy loading off and run

How do you do additional filtering on a HasMany mapping in Fluent nHibernate?

心已入冬 提交于 2019-12-04 20:31:16
In a project I'm working on, I have four entities(amongst a bunch of others), WorkOrder, Crew, CrewAssignment, and Contractor. Their relationship is like this: A WorkOrder has one Contractor, which can be changed A Crew only ever has one Contractor A CrewAssignment only ever has one Crew A WorkOrder has many CrewAssignments The problem I'm having is setting up the last part where a WorkOrder can have multiple CrewAssignments. What I want to do is ensure that the WorkOrder.CrewAssignments property only returns the CrewAssignments that have a Crew with the same Contractor as the WorkOrder. Or,

FluentNhibernate support for SQL Server 2008 R2

删除回忆录丶 提交于 2019-12-04 20:11:02
I want to implement a Fluent Nhibernate application with SQL Server 2008 R2. I am in a confusion whether Fluent Nhibernate 1.2 supports SQL Server 2008 R2. If supports what will be the configuration. Does it looks like below? var config = Fluently.Configure() .Database( MsSqlConfiguration .MsSql2008R2 .ConnectionString(@"Data Source=.\SQLEXPRESS;AttachDbFilename='FNHLD.mdf';Integrated Security=True;User Instance=True")) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<NHibernateRepository<T>>()) .BuildConfiguration(); As a matter of fact, even MsSql2005 dialect will work on SQL Server 2008 R2

NHibernate and code first

落爺英雄遲暮 提交于 2019-12-04 20:00:46
问题 Do you use SchemaExport and SchemaUpdate in real applications? Initially, you create model and then generate schema? Does it work? Or, you use it only for tests... Usually, I create db (using visual studio database project) and then mappings and persistent classes or EF entities using designer. But now, I want to try code first approach with Fluent NHibernate. I have researched SchemaExport and SchemaUpdate and found some issues. For example, update doesn't delete db objects, creates not null

Geospatial Point Mapping in Fluent NHibernate

我们两清 提交于 2019-12-04 19:51:43
I'm struggling to get Fluent NHibernate to play nice with SQL Server's Geospatial types. I want to store a geographic point in my Place class, but I keep getting an NHibernate configuration error when I run my ASP.NET MVC app: Method 'SetParameterValues' in type 'NHibernate.Spatial.Type.GeometryType' from assembly 'NHibernate.Spatial, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation. Update : This is caused by an out-dated NHibernate.Spatial DLL. Referencing the latest version (2.2+) solves the problem. Kudos to psousa for leading me to a solution. Place

Make Fluent NHibernate output schema update to file

ぃ、小莉子 提交于 2019-12-04 18:37:17
问题 I am successfully getting Fluent NHibernate to update my database by calling UpdateBaseFiles: Public Sub UpdateBaseFiles() Dim db As SQLiteConfiguration db = SQLiteConfiguration.Standard.UsingFile(BASE_DBNAME) Fluently.Configure() _ .Database(db) _ .Mappings(Function(m) m.FluentMappings.AddFromAssemblyOf(Of FluentMap)()) _ .ExposeConfiguration(AddressOf UpdateSchema) _ .BuildConfiguration() End Sub Private Sub UpdateSchema(ByVal Config As Configuration) Dim SchemaUpdater As New SchemaUpdate

one-to-one mapping is not working with 2nd-Level-Cache

只谈情不闲聊 提交于 2019-12-04 18:21:24
I have declared the fallowing mapping with NHibernate3: with FluentNHibernate public class ActivityMap : ClassMap<Activity> { public ActivityMap() { this.Table("Activity"); this.Cache.ReadWrite(); this.Version(x => x.ObjectVersion); this.Id(x => x.Id).GeneratedBy.Assigned(); // snipp this.HasOne(x => x.AppointmentRecurrence).Cascade.Delete(); } } public class AppointmentRecurrenceMap : ClassMap<AppointmentRecurrence> { public AppointmentRecurrenceMap() { this.Table("AppointmentRecurrence"); this.Cache.ReadWrite(); this.Version(x => x.ObjectVersion); this.Id(x => x.Id).GeneratedBy.Foreign(

What to be aware of when upgrading NHibernate from 1.2 to 3.2?

╄→гoц情女王★ 提交于 2019-12-04 16:43:32
Question says it all. Working with an old codebase that is using NHibernate 1.2. What do I stand to gain, and what will I lose, or experience in pain, as part of this upgrade? Is the total effort worth the benefit, and if so, what are those benefits? And while I'm at it, would it make sense to just move to Fluent NHibernate? This really depends on what nhibernate functions you are using. Take the release nodes and see if anything is in there you are using. Most functions are still working the same in 3.2. You have to do some upgrades in your mapping files. I would do one change at the time. So

NHibernate Postgresql DateTime to Time Conversion

久未见 提交于 2019-12-04 15:54:07
I'm using Fluent NHibernate to configure my mappings everything works when reading data but when trying to insert or update records that have a Postgresql type of Time I get the error message "ERROR: 42804: column \"run_time\" is of type time with time zone but expression is of type timestamp without time zone" It looks like NHibernate might be confused on which DbType to convert the DateTime to as you can see from PostgreSQL and C# Datatypes that there are several DbTypes that DateTime map to. I also tried specifying a custom type for this column from IUserType but on the NullSafeSet override

NHibernate - not-null property reference a null or transient value

試著忘記壹切 提交于 2019-12-04 15:33:40
问题 I'm getting this exception (Full exception at the bottom): NHibernate.PropertyValueException was unhandled by user code Message="not-null property references a null or transient valueClearwave.Models.Encounters.Insurance.Patient" Source="NHibernate" EntityName="Clearwave.Models.Encounters.Insurance" PropertyName="Patient" I've done a lot of Googling and it seems the most common cause for that error is when an association is bi-directional but only one half has been set. As in: Insurance