linq-to-nhibernate

Linq to NHibernate : is it mature?

*爱你&永不变心* 提交于 2019-12-01 03:22:16
I'm thinking about using Linq to NHibernate in an upcoming project, so I'd like some feedback about it. I found this identical question asked in February, and it seemed that Linq to NHibernate was not very mature at this time... Has it improved since then ? Has anyone used it in real life applications ? Thanks for your feedback PS: please do not close as duplicate : the existing question is almost 1 year old and I'm asking about the current status of the product... Ayende (one of the more vocal contributors to NHibernate) noted in a blog post this week that NHibernate's LINQ support is

NHibernate Linq and DistinctRootEntity

余生颓废 提交于 2019-11-30 23:34:42
When I execute the following query, I get an exception telling me that 'feedItemQuery' contains multiple items (so SingleOrDefault doesn't work). This is expected behaviour when using the Criteria api WITHOUT the DistinctRootEntity transformer, but when using linq, I expect to get a single root entity (FeedItem, with the property Ads (of ICollection) containing all Ads). Is there a way to tell NHibernate.Linq to use the DistinctRootEntity transformer? My query: var feedItemQuery = from ad in session.Linq<FeedItem>().Expand("Ads") where ad.Id == Id select ad; var feedItem = feedItemQuery

NHibernate / MySQL string concatenation

亡梦爱人 提交于 2019-11-30 21:08:35
I have a nhibernate linq query that looks like this: from b in session.Query<Bookmark>() where b.Uri.Equals(uri) || b.Uri.Equals("www." + uri) || string.Concat("www.", b.Uri).Equals(uri) select b This blows up, saying Concat isn't support, but when I change it to from b in session.Query<Bookmark>() where b.Uri.Equals(uri) || b.Uri.Equals("www." + uri) || ("www." + b.Uri).Equals(uri) select b It runs fine, but the query looks like this: select cast(count(*) as SIGNED) as col_0_0_ from bookmarks bookmark0_ where bookmark0_.Uri = 'www.google.com' or bookmark0_.Uri = 'www.www.google.com' or 'www.'

Does NHibernate LINQ support ToLower() in Where() clauses?

不羁岁月 提交于 2019-11-30 17:31:56
I have an entity and its mapping: public class Test { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual string Description { get; set; } } public class TestMap : EntityMap<Test> { public TestMap() { Id(x => x.Id); Map(x => x.Name); Map(x => x.Description); } } I'm trying to run a query on it (to grab it out of the database): var keyword = "test" // this is coming in from the user keyword = keyword.ToLower(); // convert it to all lower-case var results = session.Linq<Test> .Where(x => x.Name.ToLower().Contains(keyword)); results.Count(); // execute the

NHibernate Linq and DistinctRootEntity

人走茶凉 提交于 2019-11-30 17:20:22
问题 When I execute the following query, I get an exception telling me that 'feedItemQuery' contains multiple items (so SingleOrDefault doesn't work). This is expected behaviour when using the Criteria api WITHOUT the DistinctRootEntity transformer, but when using linq, I expect to get a single root entity (FeedItem, with the property Ads (of ICollection) containing all Ads). Is there a way to tell NHibernate.Linq to use the DistinctRootEntity transformer? My query: var feedItemQuery = from ad in

Eager load while using Linq in NHibernate 3

泪湿孤枕 提交于 2019-11-30 15:10:02
问题 I need help with eager loading in with Linq in NHibernate 3 trunk version. I have a many-to-many relationship like this: public class Post { public int Id {get;set;} public IList<Tag> Tags { get;set;} . . . } Now I have the following mapping in Fluent NHibernate public class PostMap:ClassMap<Post> { public PostMap() { Table("Posts"); Id(x => x.Id); . . HasManyToMany(x => x.Tags) .Table("PostsTags") .ParentKeyColumn("PostId") .ChildKeyColumn("TagId") .Not.LazyLoad(); // this is not working.. }

Extending LINQ to Nhibernate provider, in combination with Dynamic LINQ problem

泪湿孤枕 提交于 2019-11-30 14:41:20
I'm using NHibernate 3.1.0 and I'm trying to extend the LINQ provider by using BaseHqlGeneratorForMethod and extending the DefaultLinqToHqlGeneratorsRegistry as explained in Fabio's post . For example, to support ToString() I've created a ToStringGenerator as below. internal class ToStringGenerator : BaseHqlGeneratorForMethod { public ToStringGenerator() { SupportedMethods = new[] { ReflectionHelper.GetMethodDefinition<object>(x => x.ToString()) }; } public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder

Eager load while using Linq in NHibernate 3

这一生的挚爱 提交于 2019-11-30 13:28:11
I need help with eager loading in with Linq in NHibernate 3 trunk version. I have a many-to-many relationship like this: public class Post { public int Id {get;set;} public IList<Tag> Tags { get;set;} . . . } Now I have the following mapping in Fluent NHibernate public class PostMap:ClassMap<Post> { public PostMap() { Table("Posts"); Id(x => x.Id); . . HasManyToMany(x => x.Tags) .Table("PostsTags") .ParentKeyColumn("PostId") .ChildKeyColumn("TagId") .Not.LazyLoad(); // this is not working.. } } Now while fetching the posts, I need the Tags also to eager load. I know that it is possible with

How can I run NHibenate queries asynchronously?

♀尐吖头ヾ 提交于 2019-11-30 08:10:18
One way to increase scalability of the server application is to run IO-bound operation (reading files, sockets, web requests, database requests etc) asynchronously. This does not mean run them in the ThreadPool which will just block threads while operation is being executed. The correct way is to use asynchronous API (BeginRead, BeginGetResponse, BeginExecuteReader etc). The problem is well described in CLR vi C# book. Here is some article about asynchronous queries in Linq to SQL . Are any ways to execute Nhibernate query asynchonously? What about Linq to NHibernate? Thank you, Andrey As of

Does NHibernate LINQ support ToLower() in Where() clauses?

佐手、 提交于 2019-11-30 01:59:46
问题 I have an entity and its mapping: public class Test { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual string Description { get; set; } } public class TestMap : EntityMap<Test> { public TestMap() { Id(x => x.Id); Map(x => x.Name); Map(x => x.Description); } } I'm trying to run a query on it (to grab it out of the database): var keyword = "test" // this is coming in from the user keyword = keyword.ToLower(); // convert it to all lower-case var results