fluent-nhibernate

Fluent NHibernate HasMany Foreign Key Mapping Problem

萝らか妹 提交于 2019-12-03 03:54:19
I'm trying to map a simple data structure in nhibernate Tables: Employees employeeID int username varchar(30) departmentID int Departments departmentID int deptName varchar(50) My department mapping is like so: public class DepartmentMap: ClassMap<Department> { public DepartmentMap() { Id(m => m.DepartmentID).Column("departmentID"); Map(m => m.DepartmentName).Column("deptName").Length(50); HasMany(m => m.Employees); Table("Departments"); } } ... and the employee mapping public class EmployeeMap : ClassMap<Employee> { public EmployeeMap() { Id(x => x.EmployeeID, "employeeID"); Map(x => x

Fluent NHibernate mapping

為{幸葍}努か 提交于 2019-12-03 03:52:26
I'm new to NHibernate and Fluent NHibernate. Assuming I have a situation like the following Table Activities (uniquidentier ID, varchar ActivityName) Table ActivityParameters(uniqueidentifier ID, varchar ParameterName, varbinary(8000) ParameterValue) and the following class public static Acivity { ....... public virtual Guid Id {get; private set;} public virtual string ActivityName {get; private set;} public virtual IDictionary<string, object> ActivityParameters {get; private set;} } how can i write the classmap? More specifically, how can i write the mapping for activityparameters? A

MS Entity Framework VS NHibernate and its derived contribs (FluentNHibernate, Linq for NHibernate)

拈花ヽ惹草 提交于 2019-12-03 03:19:45
问题 I just read this article about the Entity Framework 4 (actually version 2). Entity Framework seems to offer a huge improvement over its first release. Thus, I have never ever used EF in any project, since I think EF is not mature enough in comparison to NHibernate. NHibernate and its current contributions of FluentNHibernate and Linq for NHibernate by Ayende Rahien My feeling is that Microsoft is solely trying to gain terrain it has lost in favor of NHibernate when the 2nd version of

Inserting parent and children with NHibernate at the same time

会有一股神秘感。 提交于 2019-12-03 02:52:00
I am attempting to save(insert) a Parent entity with list Child entities. Both entites use a Guid as primary keys. The keys are none nullable and there is no key relationship set up in the db. The save doesn't work, an exception is thrown claiming - that I am trying to save a null into Parent foreign key in the Child table. I was expecting nhibernate to create a key for the Parent and let its Child objects know about it. Is this a limitation of NHibernate or of using Guids as primary keys? This answer suggests you have to set the parent manully, is this really the only way? Here are my

Fluent Nhibernate Many to Many Mapping Way

只谈情不闲聊 提交于 2019-12-03 02:08:41
I have two classes Order and Items I want a method like this class Order { public virtual IList<Item> GetItems(Order order) { //get items for that order. } } class Item { public virtual IList<Order> GetOrders(Item item) { //get all the orders in which that items is present. } } Is it write to create a method like this or instead should I create a property public virtual IList<Item> Items { get; set; } And how should I do the mapping for this is nhibernate?? Apparently you have a many-to-many relationship: An order can have many items and an item can belong to many orders. In a relational

Fluent NHibernate one to many uni-directional mapping

落爺英雄遲暮 提交于 2019-12-03 01:59:10
I have Post and Comment classes, and they have a one to many relationship where Post has a list of Comments. How can I map this as a uni-directional relationship with Fluent NHibernate, since a comment does not need to know its parent Post? Currently, this is my mapping for Comment: Id(x => x.Id); Map(x => x.Body); References(x => x.User); and for Post: Id(x => x.Id); Map(x => x.Title); HasMany(x => x.Comments) .Inverse() .WithKeyColumn("PostId") .Cascade.AllDeleteOrphan(); This doesnt work because when I try to save a Post instance with a newly added Comment, the foreign key on Comment

Fluent Nhibernate problem (ClassMap)

对着背影说爱祢 提交于 2019-12-03 00:49:20
I have the following XML (.hbm): <property name="Geometry" column="the_geom"> <type name="NHibernate.Spatial.Type.GeometryType,NHibernate.Spatial"> <param name="subtype">MULTIPOLYGON</param> <param name="srid">-1</param> </type> </property> It´s using Nhibernate Spatial type... How can I map that property using ClassMap (Fluent Nhibernate) ? Thanks Well, I've not used NHibernate Spatial, but I browsed through the code and it looks like GeometryType inherits from IUserType so you should be able to use it with .CustomTypeIs<> For example: Map(x => x.Geometry, "the_geom").CustomTypeIs

using (Fluent) NHibernate with StructureMap (or any IoCC)

狂风中的少年 提交于 2019-12-03 00:40:22
On my quest to learn NHibernate I have reached the next hurdle; how should I go about integrating it with StructureMap? Although code examples are very welcome, I'm more interested in the general procedure. What I was planning on doing was... Use Fluent NHibernate to create my class mappings for use in NHibs Configuration Implement ISession and ISessionFactory Bootstrap an instance of my ISessionFactory into StructureMap as a singleton Register ISession with StructureMap, with per-HttpRequest caching However, don't I need to call various tidy-up methods on my session instance at the end of the

Join Unrelated tables in Fluent Nhibernate with QueryOver or CreateCriteria

可紊 提交于 2019-12-02 23:03:11
问题 I have tables : tableAnnual - AnnualAmount, AnnualCurrency. creationDate, Id tableMonthly - MonthlyAmount, MonthlyCurrency, creationDate, Id tableSharevalue - CurrentSharevalue, creationDate, Id tableMiscDetails - clientType, clientName, MarketValueAmount, creationDate I have now to do the following select with NHibernate and QueryOver: Select tableAnnual.AnnualAmount, tableAnnual.AnnualCurrency, tableMonthly.MonthlyAmount, MonthlyAmount.MonthlyCurrency, tableSharevalue.CurrentSharevalue,

Install NHibernate 3.2 with NuGet

寵の児 提交于 2019-12-02 21:53:02
I'm new to NHibernate and have been trying to get up and running with it, Fluent NHibernate and NHProf using NuGet. After reading this article ( http://gurustop.net/blog/2011/03/13/nhibernate-3-1-0-on-nuget-important-details ) it seems that v3.1 shouldn't be directly installed, however, there appears no such warning for v3.2. After successfully installing NHibernate 3.2 and NHProf using NuGet, I'm unable to install Fluent NHibernate as it says it's "Already referencing a newer version of NHibernate". Also, when I run my app I get the following error "Could not load file or assembly 'NHibernate