fluent-nhibernate

NHibernate query extremely slow compared to hard coded SQL query

泪湿孤枕 提交于 2019-12-21 17:42:12
问题 I'm re-writing some of my old NHibernate code to be more database agnostic and use NHibernate queries rather than hard coded SELECT statements or database views. I'm stuck with one that's incredibly slow after being re-written. The SQL query is as such: SELECT r.recipeingredientid AS id, r.ingredientid, r.recipeid, r.qty, r.unit, i.conversiontype, i.unitweight, f.unittype, f.formamount, f.formunit FROM recipeingredients r INNER JOIN shoppingingredients i USING (ingredientid) LEFT JOIN

FluentNHibernate: What is the effect of AsSet()?

∥☆過路亽.° 提交于 2019-12-21 12:15:39
问题 In Fluent Nhibernate what is the effect of specifying AsSet() on a HasMany or HasManyToMany relationship? Assuming the type of the mapped property is an Iesi Set, is there any difference between: HasMany(x => x.MySetProperty) .AsSet(); and HasMany(x => x.MySetProperty); 回答1: Assuming your type is an Iesi Set, then there's no difference; the HasMany call on it's own is smart enough to figure out that you want a Set. The AsSet is a way to explicitly change your HasMany to a Set in situations

NHibernate Error Message: Invalid index 3 for this SqlParameterCollection with Count=3

有些话、适合烂在心里 提交于 2019-12-21 10:57:54
问题 I have a test database design like this: The following is the pseudo-code: //BhillHeader public class BillHeader { public BillHeader() { BillDetails = new List<BillDetail>(); } public virtual int BillNo { get; set; } public virtual IList<BillDetail> BillDetails { get; set; } public virtual decimal Amount { get; set; } public virtual void AddDetail(BillDetail billdet) { BillDetails.Add(billdet); } } //BillHeader Map public class BillHeaderMap : ClassMap<BillHeader> { public BillHeaderMap() {

How do I do TDD efficiently with NHibernate?

泄露秘密 提交于 2019-12-21 09:37:09
问题 It seems to me that most people write their tests against in-memory, in-process databases like SQLite when working with NHibernate. I have this up and running but my first test (that uses NHibernate) always takes between 3-4 seconds to execute. The next test runs much faster. I am using FluentNhibernate to do the mapping but get roughly the same timings with XML mapping files. For me the 3-4 second delay seriously disrupts my flow. What is the recomended way of working with TDD and NHibernate

NHibernate, legacy database, foreign keys that aren't

♀尐吖头ヾ 提交于 2019-12-21 05:16:17
问题 The project I'm working on has a legacy database with lots of information in it that's used to alter application behavior. Basically I'm stuck with something that I have to be super careful about changing. Onto my problem. In this database is a table and in this table is a column. This column contains integers and most of the pre-existing data have a value of zero for this column. The problem is that this column is in fact a foreign key reference to another entity, it was just never defined

Unit tests for Fluent Nhibernate mappings

对着背影说爱祢 提交于 2019-12-21 05:01:00
问题 I'm trying to get a feel for how the rest of the community tests their Fluent Nhibernate mappings. So let's say I have the following mappings: public UserHeaderMap() { Table("USER_HEADER"); Id(x => x.Id, "USER_ID"); Map(x => x.LoginName, "LOGIN_NAME"); Map(x => x.UserPassword, "USER_PASSWORD"); Map(x => x.UserEmail, "USER_EMAIL"); Map(x => x.UserLanguage, "USER_LANGUAGE"); Map(x => x.UserEnabled, "USER_ENABLED"); HasManyToMany(x => x.Groups) .Table("USER_GROUP_COMPOSITE") .ParentKeyColumn(

FluentNHibernate - Setting default value for DB columns (SQL Server)

蹲街弑〆低调 提交于 2019-12-21 04:46:17
问题 does anyone know a way how I could set through mapping the default value of a column so for e.g. when I generate DB from mappings I would have DateTime column having getdate() as default value? I tried so far this (looks exactlly like what I need) but it doesn't work this.Map(x => x.LastPersistedOn, "DateModified") .Access.Property() .Default("getdate()"); 回答1: I just tried setting some default values and it worked as expected. I am using Fluent as retrieve from Git the 24.05.2010 so updating

Does Fluent-Hibernate exist?

谁说胖子不能爱 提交于 2019-12-21 03:56:06
问题 Is there something like Fluent-NHibernate for the original Java Hibernate? If not, why not? Are there any language-specific limitations? 回答1: I believe Fluent-NHibernate relies on the nice features provided by Linq in C#3.0 if I'm not mistaken. Until Java implements lambda expressions etc I don't think we'll see Fluent Hibernate. I could be wrong though. :) 回答2: Groovy supports lambda expressions (although they rather confusingly call them closures), and Groovy classes are directly accessible

which version of fluent nhibernate is compatible with nhibernate 3.2

╄→尐↘猪︶ㄣ 提交于 2019-12-21 03:49:44
问题 i see when i install fluent nhibernate 1.2 from Nuget, it downloads nhibernate 3.1. If i want to use nhibernate 3.2, how would i do that through nuget and it is compatible with fluent nhibernate 1.2 ? 回答1: Currently, the FluentNHibernate package from the offical NuGet package source, depends on NHibernate.Castle 3.1 (currently, there is no newer version yet), which in turn depends on NHibernate 3.1 (the exact version, not 3.1 or higher). Therefore, NuGet infers a dependency on NHibernate 3.1

Fluent Nhiberhate And Missing Milliseconds

本小妞迷上赌 提交于 2019-12-21 03:33:16
问题 I am using Fluent Nhibernate and Nhibernate for my current project. I need to record the time to the millisecond. I have this for my mapping Map(x => x.SystemDateTime) .CustomType("Timestamp") .Not.Nullable(); I genertaed the hbm.xml files and the line is the following: <property name="SystemDateTime" type="Timestamp"> <column name="SystemDateTime" not-null="true" /> </property> I have read this is the fix, but the records in the database do not have the milliseconds. Has anyone solved this