fluent-nhibernate

Inserting parent and children with NHibernate at the same time

寵の児 提交于 2019-12-03 13:23:55
问题 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?

how to achieve table per concrete class when base class is abstract in fluent nhibernate?

这一生的挚爱 提交于 2019-12-03 13:03:45
i have the following scenario public abstract class BaseClass { public virtual int Id {get; set}; public virtual string Name {get; set;} } public class FirstSubClass : BaseClass { //properties and behaviour here } public class SecondSubClass : BaseClass { //properties of SecondSubclass Here } public class ProcessStep { public virtual IList<BaseClass> ContentElements {get; set;} } for mapping i have used following code snippet :- this._sessionFactory = Fluently.Configure().Database(SQLiteConfiguration.Standard .ConnectionString(@"Data Source=SqliteTestSqlDataAccess.s3db; Version=3; New=True;

Fluent NHibernate HasMany Foreign Key Mapping Problem

可紊 提交于 2019-12-03 12:49:44
问题 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

NHibernate and code first

末鹿安然 提交于 2019-12-03 12:48:08
Do you use SchemaExport and SchemaUpdate in real applications? Initially, you create model and then generate schema? Does it work? Or, you use it only for tests... Usually, I create db (using visual studio database project) and then mappings and persistent classes or EF entities using designer. But now, I want to try code first approach with Fluent NHibernate. I have researched SchemaExport and SchemaUpdate and found some issues. For example, update doesn't delete db objects, creates not null columns like nullable if table exists, doesn't generate primary key on many-to-many tables and so on.

Fluent NHibernate mapping

。_饼干妹妹 提交于 2019-12-03 12:45:35
问题 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

Does Fluent-Hibernate exist?

纵饮孤独 提交于 2019-12-03 11:56:37
Is there something like Fluent-NHibernate for the original Java Hibernate? If not, why not? Are there any language-specific limitations? 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. :) Groovy supports lambda expressions (although they rather confusingly call them closures), and Groovy classes are directly accessible from Java. Perhaps the mappings for Java apps could be written in Groovy. Just a thought. chaotic3quilibrium

Fluent Nhibernate Many to Many Mapping Way

江枫思渺然 提交于 2019-12-03 11:40:20
问题 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?? 回答1: Apparently you have a many-to

NHibernate - How to map to a class that has no table (for custom sql queries)

限于喜欢 提交于 2019-12-03 11:10:20
Update - Edited config for readability in SO Hi, I've been learning NHibernate for a day or two but getting stuck on one point. I need to be able to execute custom stored procedures and use NHibernate to map them back to domain classes. I have this working for the scenario where the custom query maps back to a object that maps to a database table, as shown by many a nhibernate example (See first section below). However in the config for the second section below, the query pulls only 2 columns from the target table. For this reason, I have created a custom object so that NHibernate has

NHibernate IQueryable collection as property of root

☆樱花仙子☆ 提交于 2019-12-03 10:44:32
I have a root object that has a property that is a collection. For example: I have a Shelf object that has Books. // Now public class Shelf { public ICollection<Book> Books {get; set;} } // Want public class Shelf { public IQueryable<Book> Books {get;set;} } What I want to accomplish is to return a collection that is IQueryable so that I can run paging and filtering off of the collection directly from the the parent. var shelf = shelfRepository.Get(1); var filtered = from book in shelf.Books where book.Name == "The Great Gatsby" select book; I want to have that query executed specifically by

which version of fluent nhibernate is compatible with nhibernate 3.2

匆匆过客 提交于 2019-12-03 10:35:56
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 ? 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 when installing FluentNHibernate. So the bottom line is: you can't, until the FluentNHibernate package is