fluent-nhibernate

Linq to nhibernate - Where collection contains object with id

偶尔善良 提交于 2019-12-10 16:38:57
问题 I have 2 objects like this public class Child { public virtual int ChildId { get; set; } } public class Parent { public virtual int ParentId { get; set; } public virtual IList<Child> Children { get; set; } } I am trying to write a linq to nhibernate query to select a parent where it contains a child with a specific id. return x => x.Children.Contains does not work. I also tried this. return x => (from y in x.Children where y.ChildId.Equals(childId) select y).Count() > 0 My fluent mapping

Nhibernate uses a lot of memory

╄→尐↘猪︶ㄣ 提交于 2019-12-10 16:26:28
问题 I've got fluent nhibernate in my application and I'm trying to locate the cause of high memory usage. (I say high, it's 60MB, but it's a web app and it's not very big) Unfortunately it looks like a lot of it is in unmanaged memory, so I started taking things out - and as soon as I took out any calls to nhibernate, the memory usage dropped to 11MB!! Why oh why would it be taking up so much memory? Especially, why would it be taking up unmanaged memory? I've been 'Googling' this all day and all

What's causing “Invalid index nn for this SqlParameterCollection with Count=nn” when a column is Null in the database?

浪尽此生 提交于 2019-12-10 16:17:08
问题 For Accommodation entity we have two columns that are nullable: CollectionType and AccommodationUnitType . However I noticed in the data that they were set to zero rather than null, causing NHibernate to try and find an entity with id 0. This was a lot of extra unnecessary DB calls, so I updated the relevant data to NULL in the database, and suddenly I get a big fat error: "Invalid index 24 for this SqlParameterCollection with Count=24" Here is the mapping override I'm using: public void

Populating objects with NHibernate across multiple databases

泄露秘密 提交于 2019-12-10 16:05:33
问题 I have one SQL Server with multiple databases. Database1 has a table with a reference to IDs that are stored in a table on Database2. Not sure if it's possible, but could I configure NHibernate (Fluent NHibernate specifically) to saturate an object pulling data from multiple databases? I'm not concerned about writing to these tables, I'm just trying to ORM the objects to display in an data viewing application. I realize this isn't an ideal database situation, but it's what I was given to work

Mapping a flat view to class hierarchy in fluent nHibernate

本小妞迷上赌 提交于 2019-12-10 15:45:23
问题 I'm developing an app that has a model using race results / times etc.. I've got a model that looks something like: public class Competitor { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual DateTime DateOfBirth { get; set; } } public class Event { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual string Description { get; set; } } public class Result { public virtual int ID { get; set; } public virtual

Defining a Derived Boolean Property using Fluent NHibernate

£可爱£侵袭症+ 提交于 2019-12-10 15:39:11
问题 I have a class public class Account { public DateTime? StartDate {get;set;} public DateTime? EndDate {get;set;} public bool IsActive {get;set;} } the IsActive property is defined as a formula as .Formula(" StartDate < GETDATE() and (EndDate is NULL or EndDate > GetDate())") However when use QueryOver to query all Accounts where the IsActive == true I get an error that NHibernate cannot execute a SQL. The SQL that NHibernate generates has ...other criterias... and this_.StartDate < GETDATE()

How to specify an auto-incrementing (int) identity column using Fluent-NHibernate and MySQL

两盒软妹~` 提交于 2019-12-10 15:32:11
问题 The title basically says it all... I'm trying to specify an auto-incrementing (int) identity column using Fluent-NHibernate and MySQL. I've tried the following variations... Id(x => x.ID).GeneratedBy.Native(); Id(x => x.ID).GeneratedBy.Identity(); Id(x => x.ID).GeneratedBy.Increment(); ...and tried setting default values on each. Note: I'm using an int data type and have received errors such as... "Input string was not in a correct format." or... "Field 'ID' does not have a default value' 回答1

ArgumentOutOfRangeException : Index was out of range

不羁的心 提交于 2019-12-10 14:23:30
问题 I'm getting this weird ArgumentOutOfRangeException whenever I use the PersitenceSpecification class for verifying an entity that has a reference to a value object. public class CatalogItem : DomainEntity { internal virtual Manufacturer Manufacturer { get; private set; } internal virtual String Name { get; private set; } protected CatalogItem() {} public CatalogItem(String name, String manufacturer) { Name = name; Manufacturer = new Manufacturer(manufacturer); } } public class

How to map a dictionary with a complex key type (CultureInfo) using FluentNHibernate

久未见 提交于 2019-12-10 13:43:22
问题 I have dictionary which I'm mapping using Fluent NHibernate. The dictionary has a complex key type CultureInfo . My database can't store that type so I want to use a string representation of it. In mappings other than dictionary mappings, I can successfully map CultureInfo -properties using a user type convention. Now I wonder how to do it for dicationary mappings. Here's the entity that contains the dictionary: public class MultilingualPhrase : Entity { private IDictionary<CultureInfo,

How to generate hbm.xml file from FluentNHibernate

 ̄綄美尐妖づ 提交于 2019-12-10 12:43:54
问题 I'm trying to follow this tutorial but instead of generating the expected hbm.xml files with my mappings in it generates simple .cs class for my entities like for example: public class ProductMap : ClassMap<Product> But I already defined those myself in code. I'm after the .hbm.xml which I can use in standard NHibernate at this time. This is how I set up the SessionFactory: private static ISessionFactory CreateSessionFactory() { String schemaExportPath = Path.Combine(System.Environment