nhibernate

How to do a SELECT DISTINCT equivalent for a page filter in NHibernate?

笑着哭i 提交于 2020-01-15 06:12:08
问题 Lets say you are working in SQL 2005 with a copy of Northwind database installed. Your working on an ASP.NET application with an Employees "browse" page. At the top of the page you have a "Title" filter where you would like to display these 5 choices in a dropdown: [ALL] Vice President, Sales Sales Representative Sales Manager Inside Sales Coordinator In T-SQL you would use something like the statement below to get your list. SELECT DISTINCT Title FROM Employees ORDER BY Title What is the

How to do a SELECT DISTINCT equivalent for a page filter in NHibernate?

纵然是瞬间 提交于 2020-01-15 06:11:09
问题 Lets say you are working in SQL 2005 with a copy of Northwind database installed. Your working on an ASP.NET application with an Employees "browse" page. At the top of the page you have a "Title" filter where you would like to display these 5 choices in a dropdown: [ALL] Vice President, Sales Sales Representative Sales Manager Inside Sales Coordinator In T-SQL you would use something like the statement below to get your list. SELECT DISTINCT Title FROM Employees ORDER BY Title What is the

Avoid N+1 Select with list of NHibernate entities

◇◆丶佛笑我妖孽 提交于 2020-01-15 05:51:06
问题 I receive a list of NHibernate entities that were retrieved by code that I cannot modify. I want to select a property from a child entity for each item in the list, but it is generating a new select for each item. How can I get the sub-resources without changing the query that generated the entities passed in or changing the mapping (both of which would have an impact on unrelated code). Ideally, I wouldn't have to create a custom query at this layer of my code either. Here is a sample. My

Why does identity generator break unit of work in nHibernate? What about EF?

一曲冷凌霜 提交于 2020-01-15 05:40:10
问题 I understand and accept that the identity generator breaks the unit of work because it requires an insert prior when the transaction should actually commit, described in http://fabiomaulo.blogspot.com/2008/12/identity-never-ending-story.html. I'm aware of the alternatives and why they are better (in relation to the problem at hand, and in general). The question I have is why the implementation exists as it does, and whether or not these issues affect EF (sheer curiosity). The only real

Sql 2008 Filestream with NHibernate

我的未来我决定 提交于 2020-01-14 18:55:51
问题 I am attempting to use Filestream in sql server 2008 to store user uploaded images. My problem is that NHibernate will not error, but it also will not save the data into the database. No record is created. The Image class below is a custom class (not to be confused with System.Drawing.Image) public class ImageMap : ClassMap<Image> { public ImageMap() { WithTable("Images"); Id(x => x.ImageId).GeneratedBy.GuidComb().WithUnsavedValue(Guid.Empty); Map(x => x.ImageData); Map(x => x.Extension);

Sql 2008 Filestream with NHibernate

╄→尐↘猪︶ㄣ 提交于 2020-01-14 18:55:19
问题 I am attempting to use Filestream in sql server 2008 to store user uploaded images. My problem is that NHibernate will not error, but it also will not save the data into the database. No record is created. The Image class below is a custom class (not to be confused with System.Drawing.Image) public class ImageMap : ClassMap<Image> { public ImageMap() { WithTable("Images"); Id(x => x.ImageId).GeneratedBy.GuidComb().WithUnsavedValue(Guid.Empty); Map(x => x.ImageData); Map(x => x.Extension);

Sql 2008 Filestream with NHibernate

匆匆过客 提交于 2020-01-14 18:54:33
问题 I am attempting to use Filestream in sql server 2008 to store user uploaded images. My problem is that NHibernate will not error, but it also will not save the data into the database. No record is created. The Image class below is a custom class (not to be confused with System.Drawing.Image) public class ImageMap : ClassMap<Image> { public ImageMap() { WithTable("Images"); Id(x => x.ImageId).GeneratedBy.GuidComb().WithUnsavedValue(Guid.Empty); Map(x => x.ImageData); Map(x => x.Extension);

Fluent NHibernate - Remove Schema from Mappings for Testing With SQLite

孤人 提交于 2020-01-14 16:35:06
问题 I am trying to run some tests on my mapping using SQLite. My mappings look like the following: public class UserMap : BaseValidatableDomainMap<User> { public UserMap() { Table("blanka.[User]"); Id(x => x.Id).GeneratedBy.Identity(); Map(x => x.UserName); Map(x => x.FirstName); Map(x => x.MiddleName); Map(x => x.LastName); Map(x => x.EmailAddress); Map(x => x.OtherEmailAddress); Map(x => x.PhoneNumber); Map(x => x.City); References(x => x.Company, "CompanyId"); References(x => x.State, "StateId

NHibernate GroupBy and Sum

人盡茶涼 提交于 2020-01-14 14:48:07
问题 I am starting a study on NHibernate, and I have a problem I'm not able to solve, I wonder if someone could help me. The mapping is working "correctly" but when I try to do the grouping and the sum, the application returns the following error: "could not resolve property: Course.Price of: Persistence.POCO.RequestDetail" var criteria = session.CreateCriteria(typeof(RequestDetail)) .SetProjection( Projections.ProjectionList() .Add(Projections.RowCount(), "RowCount") .Add(Projections.Sum("Course

FluentNhibernate + private set

时间秒杀一切 提交于 2020-01-14 14:33:11
问题 I'm using auto property with private set, and fluentNhibernate throw an error for me... FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. * Database was not configured through Database method. This is my class: public class MyClass { public virtual int Id { get; set; } public virtual string PropOne { get; private set; } } This is my map: