nhibernate

Is it possible to query all objects that have one or more possible children using NHibernate?

守給你的承諾、 提交于 2020-01-05 08:06:10
问题 I have a table called Recipes which contain one recipe per row. I also have a table called RecipeIngredients which contain one ingredient as used by a particular recipe. Thus, each Recipe row has one or more children RecipeIngredients rows. What I'm trying to do is create a query to find all recipes that contain any ingredients in a list of desired ingredients. For example, show me all recipes that use either flour, eggs, or bananas. The SQL would look something like this: SELECT * FROM

Is it possible to query all objects that have one or more possible children using NHibernate?

房东的猫 提交于 2020-01-05 08:04:11
问题 I have a table called Recipes which contain one recipe per row. I also have a table called RecipeIngredients which contain one ingredient as used by a particular recipe. Thus, each Recipe row has one or more children RecipeIngredients rows. What I'm trying to do is create a query to find all recipes that contain any ingredients in a list of desired ingredients. For example, show me all recipes that use either flour, eggs, or bananas. The SQL would look something like this: SELECT * FROM

NHibernate Mapping Attributes + Dirty Checking

橙三吉。 提交于 2020-01-05 07:55:08
问题 I have problems with NHibernate updating some of my entities when this is not supposed to happen (dirty checking). As I use NHibernate.Mapping.Attributes to map my classes, I have found that there is a parameter "Check" to the element "Class" of NHMA. I would like to know if I can turn off dirty checking by setting this parameter to false or something (the required type for this parameter is string, so it may not be that). Any help would be appreciated ! 回答1: Firstly, this is not something

spring.net nhibernate session/transaction per request

人盡茶涼 提交于 2020-01-05 07:40:07
问题 Does Spring.NET have any support (integration) with NHibernate that would eneble per request ISession and transactions? I foung this blog, but it is a bit old one so I want to know if things have moved forward a bit and may be this is already integrated in Spring framework and I can only set it up with some configuration? 回答1: Yes it has, it's called "open session in view". Transaction support is available too, but it's not automatically "one transaction per request". I think a good place for

Can't get NHibernate 3.1 to log sql update or delete statements

岁酱吖の 提交于 2020-01-05 07:25:14
问题 I'm currently using NHibernate 3.1 in a ASP.Net application and got it working pretty well (with Fluent). I managed to make it log all generated SQL queries to my output tab while debugging by using the following snippet in Application_Start: private static DebugTextWriter _writer; protected virtual void Application_Start(object sender, EventArgs e) { _writer = new DebugTextWriter(); Console.SetOut(_writer); } I recently upgraded NHibernate from 2.1 to 3.1 and now my update and delete

Fluent nhibernate query where nullable int

こ雲淡風輕ζ 提交于 2020-01-05 07:17:08
问题 I have a class similar like this: public class WorkEntity { ... // other stuff here public virtual int? WorkTypeID { get; set; } } in my joined queryover I need to filter my results by WorkTypeID query.Where(() => workEntity.WorkTypeID == filter.WorkTypeID.Value); it doesn't work, because the type is nullable, how can I make it work? 回答1: query.Where(() => workEntity.WorkTypeID != null && workEntity.WorkTypeID.Value == filter.WorkTypeID.Value); 来源: https://stackoverflow.com/questions/13593292

How to Unit Test when stored procedures are used by NHibernate Mapping

寵の児 提交于 2020-01-05 07:14:09
问题 I've asked about how to inject stored procedures support when working with Views in SQL Server. How to use stored procedures in NHibernate for Create/Update when working with database view Here's a piece of mapping file: <sql-insert> exec sp_cycle_insert ?,?,? </sql-insert> <sql-update> exec sp_cycle_update ?,?,?,?,?,? </sql-update> <sql-delete> raiserror ('Cycle can not be deleted', 10, 1) </sql-delete> So, I've done the refactoring, etc, and I run my tests.... All failed. There reason is

How to Unit Test when stored procedures are used by NHibernate Mapping

早过忘川 提交于 2020-01-05 07:14:04
问题 I've asked about how to inject stored procedures support when working with Views in SQL Server. How to use stored procedures in NHibernate for Create/Update when working with database view Here's a piece of mapping file: <sql-insert> exec sp_cycle_insert ?,?,? </sql-insert> <sql-update> exec sp_cycle_update ?,?,?,?,?,? </sql-update> <sql-delete> raiserror ('Cycle can not be deleted', 10, 1) </sql-delete> So, I've done the refactoring, etc, and I run my tests.... All failed. There reason is

SharpArchitecture / Fluent NHibernate

送分小仙女□ 提交于 2020-01-05 07:08:41
问题 Does DomainSignature attribute create unique constrain in DB? Does Fluent NHibernate 1.1.0.685 supports NaturalId correctly? 回答1: Domain signature doesn't create constraints in DB. Yes Fluent NH supports Natural ID by map.NaturalId() .Property(x => x.Name) .Property(x => x.NickName); syntax 来源: https://stackoverflow.com/questions/4489576/sharparchitecture-fluent-nhibernate

Fluent NHibernate : Mapping a Class with subclass problem

戏子无情 提交于 2020-01-05 06:54:06
问题 <id name="ID" column="CodigoPessoa" type="Int32" unsaved-value="0"> <generator class="identity"/> </id> <property column="CodigoCEP" name="CodigoCEP" type="String" /> <joined-subclass name="Core.clsPessoaJuridica,Core" table="tblPessoaJuridica" lazy="true"> <key column="CodigoPessoaJuridica"/> <property column="NomeFantasia" type="String" name="NomeFantasia" /> <many-to-one name="TipoEmpresa" column="CodigoTipoEmpresa" class="Core.clsTipoEmpresa,Core" cascade="none"/> </joined-subclass>