nhibernate-criteria

Nhibernate count distinct (based on multiple columns)

久未见 提交于 2019-11-29 14:49:30
Basically, i have been trying to do this (count distinct based on two columns): select count(distinct(checksum(TableA.PropertyA, TableB.PropertyB))) from TableA left outer join TableB on TableA.TableBId = TableB.Id where PropertyA like '%123%' Been googling on how to do this but with no luck. Tried this, but never actually worked. This does not count distinctly based on the two properties from two tables: var queryOver = c.QueryOver<TableA>(); TableB tableBAlias = null; TableA tableAAlias = null; ProjectionList projections = Projections.ProjectionList(); queryOver.AndRestrictionOn(x => x

Nhibernate query for items that have a Dictionary Property containing value

假装没事ソ 提交于 2019-11-29 07:36:45
I need a way to query in Nhibernate for items that have a Dictionary Property containing value. Assume: public class Item { public virtual IDictionary<int, string> DictionaryProperty {get; set;} } and mapping: public ItemMap() { HasMany(x => x.DictionaryProperty) .Access.ReadOnlyPropertyThroughCamelCaseField(Prefix.Underscore) .AsMap<string>( index => index.Column("IDNumber").Type<int>(), element => element.Column("TextField").Type<string>().Length(666) ) .Cascade.AllDeleteOrphan() .Fetch.Join(); } I want to query all Item s that have a dictionary value of "SomeText". The following example in

Using SQL CONVERT function through nHibernate Criterion

自闭症网瘾萝莉.ら 提交于 2019-11-28 13:58:23
I have a sql view, in which the data type of every column is string , for use with the jquery datatables plugin. One of the columns contains a uk format date dd/mm/yyyy. This column needs to remain a string to work with the keystroke filtering of the plugin, however for sorting it needs to be treated as a date. I am using nhibernate criteria to create the sql query and I want to generate the following order by clause, as this orders the dates correctly order by CONVERT (datetime, DateOfBirth, 103) However in Nhibernate.Criterion.Projections there is no Convert method. There is Cast , but I get

Fetching Paginated Entity with Collection

耗尽温柔 提交于 2019-11-28 11:32:34
问题 Consider two entities Person which has a one-to-many collection Vehicles public class Person { public IList<Vehicle> Vehicles { get; set;} } public class Vehicle { public string Name { get; set;} public Person Owner { get; set; } } I display a grid of Persons having vehicle and show the name of the first vehicle in the grid. The grid is paginated. I use the following criteria to fetch the data I have a criteria for loading data for a grid view as var criteria = DetachedCriteria.For<Person>()

Fluent NHibernate - ProjectionList - ICriteria is returning null values

﹥>﹥吖頭↗ 提交于 2019-11-28 09:32:08
问题 I'm quite new in NHibernate, but I have googled around and didn't found anything to help with this issue. I hope you guys can ! ;) I'm changing names of properties, and methods, because this code is company's property but basically this is what I need some help. I have the following scenario: My Domain Entity: public class Structure { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual Person Manager { get; set; } //I need to fill here. //and others }

Nhibernate query for items that have a Dictionary Property containing value

荒凉一梦 提交于 2019-11-28 01:05:20
问题 I need a way to query in Nhibernate for items that have a Dictionary Property containing value. Assume: public class Item { public virtual IDictionary<int, string> DictionaryProperty {get; set;} } and mapping: public ItemMap() { HasMany(x => x.DictionaryProperty) .Access.ReadOnlyPropertyThroughCamelCaseField(Prefix.Underscore) .AsMap<string>( index => index.Column("IDNumber").Type<int>(), element => element.Column("TextField").Type<string>().Length(666) ) .Cascade.AllDeleteOrphan() .Fetch

NHibernate AliasToBean transformer associations

流过昼夜 提交于 2019-11-26 11:24:02
I'm trying to use the following statement to get an entity with the fields I'm after: retVal = session.CreateCriteria(typeof(MyEntity)) .CreateAlias("MyEntityProperty", "MyEntityProperty") .Add(Restrictions.Eq("MyEntityProperty.Year", year)) .SetProjection( Projections.Distinct( Projections.ProjectionList() .Add(Projections.Property("Property1"), "Property1") .Add(Projections.Property("Property2"), "Property2") .Add(Projections.Property("MyEntityProperty.RegisteredUser"), "MyEntityProperty.RegisteredUser") .Add(Projections.Property("MyEntityProperty.CompanyInfo"), "MyEntityProperty.CompanyInfo

NHibernate AliasToBean transformer associations

落花浮王杯 提交于 2019-11-26 02:24:09
问题 I\'m trying to use the following statement to get an entity with the fields I\'m after: retVal = session.CreateCriteria(typeof(MyEntity)) .CreateAlias(\"MyEntityProperty\", \"MyEntityProperty\") .Add(Restrictions.Eq(\"MyEntityProperty.Year\", year)) .SetProjection( Projections.Distinct( Projections.ProjectionList() .Add(Projections.Property(\"Property1\"), \"Property1\") .Add(Projections.Property(\"Property2\"), \"Property2\") .Add(Projections.Property(\"MyEntityProperty.RegisteredUser\"), \