linq-to-nhibernate

Order by relation count in NHibernate

有些话、适合烂在心里 提交于 2019-12-19 12:12:33
问题 I have a datastructure like this: public class User { public Guid Id {get;set;} public string Name {get;set;} public IList<Books> Books {get;set} } I have been struggeling with making it possible to sort the users by the count of bookmarks (one-to-many relation). I have tried various approaches with both linq, criteria and queryover, but with no luck, and therefore hope one of you could help. I am using paging, since I have quite a few users, so the solution needs to do the query on the SQL

Order by relation count in NHibernate

扶醉桌前 提交于 2019-12-19 12:12:08
问题 I have a datastructure like this: public class User { public Guid Id {get;set;} public string Name {get;set;} public IList<Books> Books {get;set} } I have been struggeling with making it possible to sort the users by the count of bookmarks (one-to-many relation). I have tried various approaches with both linq, criteria and queryover, but with no luck, and therefore hope one of you could help. I am using paging, since I have quite a few users, so the solution needs to do the query on the SQL

Linq to NHibernate : is it mature?

浪尽此生 提交于 2019-12-19 05:17:11
问题 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... 回答1: Ayende (one of the

NHibernate / MySQL string concatenation

点点圈 提交于 2019-12-19 03:21:06
问题 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

How can I run NHibenate queries asynchronously?

冷暖自知 提交于 2019-12-18 12:49:29
问题 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

LINQ-to-NHibernate: Cannot use Linq Skip() and Take() with FetchMany

匆匆过客 提交于 2019-12-14 02:06:54
问题 I have these entities: public class BlogPost { public virtual int Id { get; set; } public virtual IList<Keyword> Keywords { get; set; } public virtual IList<BlogComment> Comments { get; set; } } public class BlogComment { public virtual int Id { get; set; } public virtual BlogPost Post { get; set; } } public class Keyword { public virtual int Id { get; set; } public virtual IList<BlogPost> BlogPosts { get; set; } } I want to load a paged-list of BlogPost s by their Keyword s and comments

FirstOrDefault() breaks FetchType=join with Linq to NHibernate

自作多情 提交于 2019-12-13 12:41:52
问题 If i do Session.Linq<MyClass>().Where(x => x.Id = someId).FirstOrDefault(); where MyClass has a set of eager loaded child object on it, the FirstOrDefault() seems to prevent this from working by adding a TOP 1 to the SQL. Is this just a bug (feature?) in Linq2NH (which i understand is being rewritten) or am I missing something? Is there a preferred alternative which works properly? Thanks 回答1: Looks like a bug, in my opinion FirstOrDefault is a pretty well defined Linq operator and it has

nHibernate - IStatelessSession and FetchMany returning multiple parent records

巧了我就是萌 提交于 2019-12-12 20:23:41
问题 I have the following linq statement: var query = from p in session.Query<Parent>().FetchMany(x => x.Children) select p; I end up with a new Parent object for each Child in Children. So if i had 5 Children, I would get 5 separate, but identical, Parent objects back. Is this the intended behavior? If i use ISession, I get 1 Parent as expected. 回答1: This is expected, because Stateless Sessions do not track objects; therefore each row results in a new instance. 回答2: Have you tried to do a

NHibernate.Linq System.Nullable throws ArgumentException, the value “” is not type

天涯浪子 提交于 2019-12-12 18:20:56
问题 I have a class of type MetadataRecord: public class MetadataRecord { public virtual long? IntegerObject { get; set; } public virtual string ClassName { get; set; } public virtual DateTime? DateObject { get; set; } public virtual double? DecimalObject { get; set; } public virtual long MetadataId { get; set; } public virtual long MetadataLabelId { get; set; } public virtual long ObjectId { get; set; } public virtual string StringObject { get; set; } public virtual Asset Asset { get; set; } }

NHibernate Query<T> with detached criteria…

旧街凉风 提交于 2019-12-12 12:56:31
问题 I have that : var query = session.Query<MyClass>(); // Here I need to execute a detached criteria, like that : // query.UnderlyingCriteria.Add(SpatialExpression.Within("Geo", extent)); var t = query.Select(item => new MyClassView { Name, Year, Code } Is that a way to do that with Query ? Or maybe another way? I need a IQueryable result... Thanks 回答1: the linq provider does not use Criteria under the covers, it uses the AST from the HQL parser. If you really need an IQueryable then you could