Group by date with LINQ to NHibernate -


In the LINQ implementation of NHibernate, there is a problem with an unsupported feature (this is firing a QueryException

>:" Property can not be solved: created: date: example comment ").

Looking at the unit below, I am compiling the comments per day and the amount of comments :

  public class comment {public virtual date time { Get  (usually have additional properties and correct mapping, written in Fluent NHibernate)  set; }}  

My LINQ query appears below (query works fine if LINQ is executed for SQL reference).

  var commentsPerDay = (in the session. Linak  () Select new in Group {New} in {c.CreatedOn.Date} by Group C {date = g.Key. Date, Count = g.Count ()};  

The appropriate solution will have to contribute to the project and fix this issue.

On the other side, let me know (LINQ to) NHibernate has an extensibility point, where I inject this behavior. I know that I can probably create a custom type and date of creation time I can mapping the second asset in part, but I'm guessing it will not translate into a query, which will make it very slow.

I have limited access to writing the questions again Because they have to work on LINQ from SQL, so I can not use HQL.

I have only got one solution for this and it is to do the following:

All results The Unen Nhibernate, and then forced to get results. Then you can make a group on the results.

This will look something like this:

  var comment = session.ink < Comment & gt; (). Select (s = & gt; new {s.CreatedOn}). List (); // Receive all comments in the results var comments and notes = comments. GroupB (C = & gt; c.CreatedOn.Date). Select (foo = & gt; new {date = g., Calculation = g. Counts ()); // The result by the group  

Sorry, I love the noble, but I think you will get this idea. You might want to limit the date range for the query so that you can not withdraw results many times.

(I previously signed in with Google in wrong user and was posted under User.)


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -