fluent-nhibernate

Fluent NHibernate Child collection persistence issues

柔情痞子 提交于 2019-12-20 04:34:36
问题 I have the following mapping classes (only the relevant part copied): public class CardTemplateMapping : ClassMap<CardTemplate> { public CardTemplateMapping() { Table("cardtemplate"); Id(x => x.Id) .Column("id") .GeneratedBy.Native(); HasMany(x => x.CostStructures) .KeyColumn("cardtemplate_id") .Cascade.All(); } } public class CostStructureMapping : ClassMap<CostStructure> { public CostStructureMapping() { Table("coststructure"); Id(x => x.Id) .Column("id") .GeneratedBy.Native(); References(x

Fluent Mapping Many-Many with sorting

微笑、不失礼 提交于 2019-12-20 03:40:33
问题 I'm trying to get a many to many relationship to work using Fluent Nhibernate. I have a Product and a RelatedProduct Table Product {Id, Name...} ProductRelated{Id, ProductId, RelatedProductId, relOrder} and a Product class The mapping looks like HasManyToMany(x => x.RelatedProducts) .Table("ProductRelated") .ReadOnly() .ChildOrderBy("relOrder asc") .ParentKeyColumn("ProductId") .ChildKeyColumn("RelatedProductId"); When a query is done for Product and the RelatedProducts are lazy loaded I can

Nhibernate/Linq: NHibernate.QueryException : could not resolve property: Profile.class of: MyNamespace.MyObject

那年仲夏 提交于 2019-12-20 03:35:09
问题 I'm having an issue with my linq query. I am trying to filter objects based on selected values. We use a query model which returns a System.Linq.Expressions.Expression and uses it to create an nhibernate query. Here is my linq expression. x =>(request.InitialLoad || (!request.InitialLoad && (Enum.GetValues(typeof(MyType)).Length == request.MyTypes.Length || (Enum.GetValues(typeof(MyType)).Length != request.MyTypes.Length && ((request.MyTypes.Contains((int)MyType.Referrals) && x.Post.PostType

fluent nhibernate truncate string automatically

别等时光非礼了梦想. 提交于 2019-12-20 03:31:07
问题 Is there an easy way to automatically truncate strings using fluent nHibernate mappings. I would prefer to not address this the setters or a custom type, but with something in the mapping files. 回答1: If I understand you correctly you want to make sure strings persisted to the database are no longer than a specified length. This sounds like it could be a business concern though and probably does belong in the domain model or as validation logic. This question appears to have been asked before

How do I configure FluentNHibernate to not overwrite an existing SQLite db file?

老子叫甜甜 提交于 2019-12-20 03:19:13
问题 Here is my configuration: this.factory = Fluently.Configure(). Database(SQLiteConfiguration.Standard.UsingFile("foo.db"). ShowSql()). Mappings(m => m.FluentMappings.AddFromAssemblyOf<Bar>()). ExposeConfiguration(BuildSchema). BuildSessionFactory(); BuildSchema looks like this: private static void BuildSchema(Configuration config) { new SchemaExport(config).Create(false, true); } Luckily this works great and creates a file named foo.db to which I can read and write. Unluckily, every time i run

Fluent Nhibernate AutoMapping — 2 foreign keys to same table?

℡╲_俬逩灬. 提交于 2019-12-20 03:16:36
问题 Let say I'm doing a basic transaction system where I have the following objects. public class User { public virtual int Id{get; set;} } public class Transaction { public virtual int Id{get; set;} public virtual Item Item {get; set;} public virtual User Seller{get; set;} public virtual User Buyer{get; set;} } Notice how I have two relationships back to the User object. When FHN generates the table schema I get 3 FK relationships from the transaction table back to the User table, "Buyer_id",

Fluent NHibernate Composite ID table problem

不打扰是莪最后的温柔 提交于 2019-12-20 03:05:38
问题 I'm kinda new to nhibernate and i ran into a problem. I have the following tables: Table 1: Table Name: Users, Column 1: ID, Column 2: Name Table 2: Table Name: Missions, Column 1: ID, Column 2: Description Table 3: Table Name: UserToDoMissions, Column 1: UserID, Column 2: MissionID, Column 3: Rank Here is the code: MissionMap: public class MissionMap : ClassMap<Mission> { public const string TableName = "tblMissions"; public const string c_id = "achID"; public const string c_name = "achName"

Fluent NHibernate: How to create a clustered index on a Many-to-Many Join Table?

余生颓废 提交于 2019-12-20 01:44:16
问题 In order to use my Fluent NHibernate mappings on SQL Azure, I need to have a clustered index on every table. The default heap tables that Fluent NHibernate creates for many-to-many joins obviously don't do this as they don't have primary keys. I want to be able to tell one side of the relationship to create a clustered index for its join table, but I'm not sure how. Here's what my mappings look like: public class UserMap : ClassMap<User>{ public UserMap() { Table("Users"); Id(x => x.UserId)

How do I map an ICompositeUserType

点点圈 提交于 2019-12-19 21:46:54
问题 I am porting a simple working demo from nhibernate to fluent. My existing nhibernate mapping is this: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MoneyHibernate" namespace="MoneyHibernate"> <class name="Invoice" table="Invoices"> <id name="Id"> <generator class="guid"/> </id> <property name="Number"/> <property name="Customer"/> <property name="TotalValue" type="MoneyHibernate.MoneyCompositeUserType,MoneyHibernate"> <column name=

How do I map an ICompositeUserType

冷暖自知 提交于 2019-12-19 21:45:55
问题 I am porting a simple working demo from nhibernate to fluent. My existing nhibernate mapping is this: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MoneyHibernate" namespace="MoneyHibernate"> <class name="Invoice" table="Invoices"> <id name="Id"> <generator class="guid"/> </id> <property name="Number"/> <property name="Customer"/> <property name="TotalValue" type="MoneyHibernate.MoneyCompositeUserType,MoneyHibernate"> <column name=