linq-to-nhibernate

Get item index (rownum)

偶尔善良 提交于 2019-12-12 09:57:10
问题 I have table with 10 000 elements. IQuerable<IEntity> query = dataRep.Get<IEntity>() .Query(); I need to get the index(rownum) of selected obj without getting all table items var obj = query.Where( x => x.Name == "testName") .FirstOrDefault(); The simple sql work fine : select name, id, r from ( select name, id, rownum r from collections order by id ) where name = 'testName'; How do this in Linq to NHibernate ? Edit: I tried add to IEntity class property RowNumber and mapping this on hbm as

Linq to NHibernate project status? Contributing? Lead? [closed]

浪尽此生 提交于 2019-12-12 07:19:52
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Anyone knows what is the status of the Linq to NHibernate project? Is it in any kind of "production"? Cannot find the project site (bug reports, feature requests, people etc.), so that I could try to contribute? The latest post I was able to find was about Linq to NHibernate in LinqPad, and some Ayende's posts

Querying with linq a collection mapped as a map (IDictionary)

时间秒杀一切 提交于 2019-12-12 02:28:08
问题 Using NHibernate, I have a collection of entities mapped as a dictionary. By example, class A has a collection of B named Children , mapped as a IDictionary<int, B> . B has a property Name . Querying class A base on some condition on B children unrelated to their dictionary indexation is quite straightforward with HQL : from A where A.Children.Name = 'aName' Runs flawlessly. But for achieving the same with LINQ , this is quite less straightforward: IQueryable<A> query = ...; query.Where(a =>

Why am I getting this Linq to Nhibernate exception when I add the same expression to the query twice?

坚强是说给别人听的谎言 提交于 2019-12-11 17:48:55
问题 I have a problem. I'm getting an "An item with the same key has already been added." exception when I try to enumerate over the query results. It happens when I try to include an expression from the same original variable in the final query. I tried to get around this by copying the expression but to no avail: var predicate1 = PredicateBuilder.True<SomeType>(); var predicate2 = PredicateBuilder.True<SomeType>(); var predicate3 = PredicateBuilder.True<SomeType>(); System.Linq.Expressions

NHibernate HQL Generator Caching Expression

非 Y 不嫁゛ 提交于 2019-12-11 13:07:15
问题 I have created the following NHibernate HQL generator: public class ContainsGenerator : BaseHqlGeneratorForMethod { public ContainsGenerator() { SupportedMethods = new[] { ReflectionHelper.GetMethodDefinition(() => MyExtensions.Contains(null, null)) }; } public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor) { var exp = FormatExpression((string)((ConstantExpression

Dynamic linq-to-nhibernate query problem

六月ゝ 毕业季﹏ 提交于 2019-12-11 10:23:19
问题 Suppose I have classes Foo and Bar as follow: public class Foo { public string F1 {set; get;} public string F2 {set; get;} public Bar ContainerBar {set; get;} } public class Bar { public string B1 {set; get;} public string B2 {set; get;} public List<Foo> Foos {set; get;} } Following linq query has errors saying that foo does not contain a property named F1 . var query = from foo in session.Linq<Foo>() select foo.ContainerBar; query = query.Where(foo => foo.F1 == "abcdef"); I know foo in

NHibernate 3CR1: Conversion to Sql, generates sql syntax problem of unnecessary brackets

二次信任 提交于 2019-12-11 07:32:49
问题 My database schema is described below: Form <-> Log <--->>Seller1 <--->>Seller2 <--->>Seller3 I have a major entity (Form), one to one relationship to another object (Log) And one to many relationship to the childs (Sellers). I want to pull out all the Forms that one of their Sellers meets certain conditions. Unfortunately I'm having some problems: If I run the following routine: [Test] public void Can_Get_Forms_Where_CorporationNumber_Is_510778087_Metohd0() { var CorporationNumber =

How to implement limit with Nhibernate and Sybase

三世轮回 提交于 2019-12-11 03:16:39
问题 We use Nhibernate 3.3 to connect to our Sybase Ase 15 database. Everything is fine except for the non support of the limit (or top). It is implemented in sybase but not in Nhibernate. Do you have a solution? I tried to create a CustomSybaseAse15Dialect where I change this: public override bool SupportsLimitOffset { get { return true; } } public override SqlString GetLimitString(SqlString sql, SqlString offset, SqlString limit) { int insertionPoint = GetAfterSelectInsertPoint(sql); if

Linq to NHibernate produces unnecessary JOINs

廉价感情. 提交于 2019-12-11 02:53:39
问题 I am using NHibernate 3.2.1. The following query return session.Query<TmTranslation>() .Where(x => x.TranslationUnit.Document.Job == job) .OrderBy(x => x.Id) .ToList(); produces this SQL: select tmtranslation.id, tmtranslation.text, tmtranslation.fk_id_translation_unit from "TRANSLATION" tmtranslation inner join "TRANSLATION_UNIT" tmunit on tmtranslation.fk_id_translation_unit = tmunit.id inner join "TRANSLATION_UNIT" tmunit2 on tmtranslation.fk_id_translation_unit = tmunit2.id inner join

Bound FetchMany in Linq to NHibernate

*爱你&永不变心* 提交于 2019-12-11 01:55:28
问题 I am using FetchMany for some of my queries and the NHibernate profiler gives me the following error: WARN: firstResult/maxResults specified with collection fetch; applying in memory! I guess this is because the fetch is unbound. Is there a solution to this? 回答1: This problem arises because using FetchMany will bring the whole result set to memory and then Take the specified subset (something inefficient and potentially dangerous). Apparently there is no way to limit the subset before