nhibernate

NHibernate: how to sort a collection by a property of a referenced entity

北战南征 提交于 2019-12-23 03:36:09
问题 I would like to to sort CampaignRetailers by Retailer.Name. However Retailer is a referenced entity on CampaignRetailers. I've tried order-by="Retailer.Name" . Is this kind of sorting possible? <class name="Campaign" table="Campaign"> <id name="Id"> <generator class="identity"/> </id> <set name="CampaignRetailers" table="CampaignRetailers" cascade="all-delete-orphan" inverse="true" order-by="Retailer.Name"> <key column="CampaignId" not-null="true" /> <one-to-many class="CampaignRetailer" /> <

NHibernate Mapping a Many to Many with Data on Join Table

佐手、 提交于 2019-12-23 03:29:13
问题 I have a User table and an Address table. They are connected by a join table. The mapping for that is straight forward, but I have some data on the join table that I would like to show up on the Address table. There may be a better way to set this up also, which I'm open to suggestions for. Here is the table structure. CREATE TABLE [dbo].[User] ( [Id] INT NOT NULL IDENTITY PRIMARY KEY, ... ) CREATE TABLE [dbo].[Address] ( [Id] INT NOT NULL IDENTITY PRIMARY KEY, ... ) CREATE TABLE [dbo].

nHibernate & sqlite mappings

烈酒焚心 提交于 2019-12-23 03:23:35
问题 I'm having real problems with setting up nHibernate with sqlite. Here is the hibernate.cfg.xml file: <?xml version="1.0" encoding="utf-8" ?> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="dialect">NHibernate.Dialect.SQLite20Dialect</property> <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property> <property name=

Fluent NHibernate Many to Many with extra column does not insert

谁都会走 提交于 2019-12-23 03:23:29
问题 I'm struggling with fluent nhibernate from Fluent Nhibernate Many-to-Many mapping with extra column I've copied the mappings and written the smallest program I can... but it wont save... Would anybody be able to provide some insight ??? public class Product { public int Id { get; set; } public string Name { get; set; } public IList<Inventory> Inventory { get; set; } public Product() { Inventory = new List<Inventory>(); } } public class Warehouse { public int Id { get; set; } public string

MVC3 NHibernate, SQL audit

雨燕双飞 提交于 2019-12-23 03:16:10
问题 I have some misunderstandings about the implementation of an SQL audit module , using as ORM Fluent NHibernate . So here is the situation: We are talking about a Client-Server application build on MVC3 framework. Suppose there we have a method which renders the grid : [HttpGet] public ActionResult ShowGrid() { var gridModel = _gridService.GetAllRecords(); return View(gridModel); } Now when somebody executes a DB Inser/Update/Delete command, I want that every client which views that grid to

MVC3 NHibernate, SQL audit

北慕城南 提交于 2019-12-23 03:16:04
问题 I have some misunderstandings about the implementation of an SQL audit module , using as ORM Fluent NHibernate . So here is the situation: We are talking about a Client-Server application build on MVC3 framework. Suppose there we have a method which renders the grid : [HttpGet] public ActionResult ShowGrid() { var gridModel = _gridService.GetAllRecords(); return View(gridModel); } Now when somebody executes a DB Inser/Update/Delete command, I want that every client which views that grid to

In Linq-to-Nhibernate, is it possible to use .Fetch() after a .Select()?

人走茶凉 提交于 2019-12-23 03:01:12
问题 If I had an Object A that contained a many-to-one reference to Object B, where Object B contained a one-to-many collection of Object C... consider the following query: IQueryable<A> query = getIQueryableSomehow(); List<B> resultList = query.Where(A => A.whatever == something).Select(A => A.B).Fetch(B => B.C).ToList(); I want to do something similar to this, but I keep getting a null reference exception with this code. Is there a sneaky trick to achieve this kind of query AND fetch a bunch of

Union with NHibernate and Criteria?

瘦欲@ 提交于 2019-12-23 02:59:09
问题 Union with NHibernate and Criteria: Is it possible in Criteria or QueryOver? If not, is there any other way to achieve a union of two result within the same query? 回答1: You can't do a union directly, but you can do two future queries and union the results in code: var resultSet1 = this.Session.CreateCriteria<A>().Future<A>(); var resultSet2 = this.Session.CreateCriteria<B>().Future<B>(); After this, when either result set is enumerated, NHibernate will issue a single query to the database

Tutorial About IoC + NHibernate + MVC

余生颓废 提交于 2019-12-23 02:53:12
问题 I was following up Jason Dentler's series of posts on how to use NHibernate + Ioc (Ninject) with a real world ASP.NET MVC N-Tier application. Sadly he dropped the series. Does anyone has any good suggestions of articles that cover a similar scenario? I would be very interesting in learning such things. 回答1: Bob Cravens TruckTracker turorials utalise MVC, NHibernate, Ninject and MySQL. I have found them to be an invaluable resource. 回答2: I don't know about tutorials but I think that you should

Updating child instead of deleting it

≯℡__Kan透↙ 提交于 2019-12-23 02:52:45
问题 Look at the entity - class Person { int id { get; set; }; IList<PersonAddress> Addresses { set; get; } ... } Now while updating person from UI if I just remove some addresses from the list of address then I wand to actually delete the address record from db. currently this is updating the address table setting personId = NULL and not deleting the address record. Does anyone know how to do this. may be some mapping issue. Here I am adding whole Person class mapping file. public class