fluent-nhibernate

Fluent NHibernate HasMany Collection Problems

萝らか妹 提交于 2020-01-05 09:15:30
问题 Update: It appears that changing my mapping from Cascade.All() to Cascade.AllDeleteOrphan() fixes most of my issues. I still have to explicitly set the Company property on the OperatingState, which seems unnecessary as it's being added to the Company entity, but at least I can work with that during an update. I still need to test that with a create. If any one can explain that, that would be a big help. Update 2: After playing with it some more, it appears I don't always have to specify the

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

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

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>

Fluent NHibernate Mapping for DDD Model

ぃ、小莉子 提交于 2020-01-05 05:59:07
问题 I have been trying to look for solutions to the problem that I am currently having with mapping my DDD model using Fluent NHibernate. If someone can just put me in the right direction that would be appreciated. Basically I have this class that I would like to map: public class A : EntityObject { //assuming some other attributes have been mapped properly public virtual Location MyLocation { get; private set; } } public class Location : EntityObject { public virtual string Name { get; private

AutoMapping a Composite Element in Fluent Nhibernate

坚强是说给别人听的谎言 提交于 2020-01-05 04:38:07
问题 I'm trying to get the AutoPersistence model to map several composite elements. However, it seems that either I end up mapping it as an entity, dropping down to manual mapping or it just doesn't plain work. Here's some code that demonstrates my problem: using System; using System.Collections.Generic; using FluentNHibernate.AutoMap; using FluentNHibernate.Cfg; using FluentNHibernate.Conventions.Helpers; using NHibernate.Cfg; namespace Scanner { public class Root { public int Id { get; set; }

Fluent NHibernate: How to create circular one-to-one mapping?

╄→гoц情女王★ 提交于 2020-01-05 03:33:45
问题 public class AdminUser { public virtual int Id { get; set; } public virtual string UserName { get; set; } public virtual string Password { get; set; } public virtual bool IsLocked { get; set; } public virtual AdminUser Creator { get; set; } public virtual DateTime CreationDate { get; set; } } public class AdminUserMapping : ClassMap<AdminUser> { public AdminUserMapping() { Id(c => c.Id).GeneratedBy.Native(); Map(c => c.UserName).Not.Nullable(); Map(c => c.Password).Not.Nullable(); Map(c => c

How to escape colon (:) character while executing native SQL queries against an Informix database using NHibernate?

故事扮演 提交于 2020-01-04 18:17:26
问题 I'm trying to execute a set of native SQL queries against an Informix database, using NHibernate to create the queries. However, NHibernate is set to change the query if it contains colons (they are supposedly reserved characters), and so the query fails. This is a sample of the native SQL query: CREATE PROCEDURE procedure_name() ... SELECT FIRST id :: INTEGER INTO variable ... END PROCEDURE; which NHibernate transforms into this, before executing the query, CREATE PROCEDURE procedure_name()

Linq: select property collection

我的未来我决定 提交于 2020-01-04 13:47:43
问题 I have two classes: public class Person { public int Id{get;set;} public string Name{get;set;} public List<Order> Orders{get;set;} } public class Order { public int Id{get;set;} public string Data{get;set;} public decimal Sum{get;set;} } I use Nhibernate Linq. If I want to get total sum of orders filtering by Persan.Name I do this: var result = (from person in personRepository.Query from order in person.Orders where person.Name.Contains("off") select order).Sum(order => order.Sum); How can I