This is a migrated thread and some comments may be shown as answers.

When will Grouping be supported

22 Answers 332 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alfred Ortega
Top achievements
Rank 2
Alfred Ortega asked on 21 Nov 2008, 10:12 PM
I ran (or attempted to run) a Linq Statement with Grouping and found out that that is not supported.  Will that be supported in the next hotfix or version?

[Edit]
Are there any other not yet Linq supported features?
[/Edit]

Thanks in advance,
Al

22 Answers, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 24 Nov 2008, 01:45 PM
Hi Alfred Ortega,

why do you want to use grouping? We don't support this yet as we have not seen a good fit for it because of it's semantics wrt. SQL. Be aware, that there is an difference between grouping and nested ordering. Grouping is purely about ordering a new table based on aggregate values, whereas nested ordering allows more flexible sorting.
SQL Grouping therefore could only return projections like max/min/average/sum, which does not fit very well to an object or class oriented programming. With other words: With SQL grouping you would never get back your persistent objects, but some new artifical structures which contain aggregate information only.

Best wishes,
Thomas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Alfred Ortega
Top achievements
Rank 2
answered on 24 Nov 2008, 02:05 PM
Thomas,
I do want the aggregrate functionality so I think it's very useful.  Here is a scenario that I'm using for.  A user conducts a search of vehicles entering in their search criteria in a TextBox - pretty standard.  Now they get x number of results based on that search.  I'm not going to show all of them, they are going to get paged 10 or 25 at a time or something - again pretty standard.  I also want a tag cloud based on their search and the weight of the tag is the count of tag for vehicles matching their search so it is an aggregrate need.

I was also going to do it using a view but openaccess doesn't seem to support them via the wizard yet and I don't know enough about the config files to play with it. 

Also as more and more people get familiar with Linq they will expect that standard Linq functionality and slightly more advanced functionality (grouping, joins, max, min) will be supported by products that say, "Use familiar LINQ constructs when you query your database" like your site says. :-)

Al
0
Alfred Ortega
Top achievements
Rank 2
answered on 26 Nov 2008, 01:33 PM
So will grouping be supported?

Al
0
Thomas
Telerik team
answered on 26 Nov 2008, 02:44 PM
Hello Alfred,

yes, grouping will be supported in a future version (this future is not that far away). An exact date cannot be given yet and depends on the approved roadmap.

Greetings,
Thomas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
joshuarivers
Top achievements
Rank 2
answered on 05 Dec 2008, 08:18 AM
It's worth noting that there are several work-arounds here.

You can manually map to a View which has your grouped information.
You can wait for Q1 and use sprocs to return your grouped information.
You can return the whole set and use linq to group and aggregate client side.

That all said, I just built my first sample app with OpenAccess, and the _second_ thing I grabbed for was grouping. Priority for the roadmap, please!
0
Peter Brunner
Telerik team
answered on 05 Dec 2008, 08:39 AM
Hi Alfred,

we appreciate your feedback. It is on the roadmap for Q2/2009 and got priority. If we have a chance to move it into Q1 we will do.

Sincerely yours,
Peter Brunner
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
joshuarivers
Top achievements
Rank 2
answered on 05 Dec 2008, 06:17 PM
Eh. Not alfred. But thanks!
0
Alfred Ortega
Top achievements
Rank 2
answered on 05 Dec 2008, 06:25 PM
Thanks!  What about joins, and other Linq functionality?  Will it be a full Linq implementation?
0
Thomas
Telerik team
answered on 08 Dec 2008, 02:05 PM
Hello Alfred Ortega,

what is that you really need to have? LINQ can be complex to implement, and some features might not be necessary to have in the first place. Explicit joins f.e. can be much more efficiently expressed by using the corresponding references in the object model. And server side method execution will be limited to things expressable in T-SQL/PLSQL ...

Best wishes,
Thomas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Alfred Ortega
Top achievements
Rank 2
answered on 08 Dec 2008, 05:18 PM
I'll give you a list that would work for me and try to be specific so that is hopefully of value to you.  Also you may have some of these implemented and if so I apologize I haven't had a lot of time to test everything - ;-)

1) Aggregrate functions.  Grouping, Avg and Sum specifically
2) Anonymous types - I think you have this already.
3) Column functions - StartsWith, Contains, EndsWith etc...
4) Skip/Take and Single - I think you have this already too.
5) Joins.  Yes you can do them via PL/SQL or T-SQL but the point of Linq is to abstract that away so I don't have to. In some cases like simple joins the SQL is pretty simple so the overhead of the extra sproc/packages is unneeded.

Things I'm not really too concerned with and can wait.

1) Lambda expressions
2) Reverse - After all I can just sort desc...
3) Range - We've got skip/take so I'm happy with that.

Hope that listing helps you
Al
0
joshuarivers
Top achievements
Rank 2
answered on 08 Dec 2008, 09:36 PM
Something I've been thinking about is that in addition or alternative to the LINQ support for queries/projections I'd like to see:

Mapping of arbitrary SQL queries to read-only objects/collections. I'd like to go into the mapping wizard, and enter a query and have it create a class based on the result so that I can bind my grids and UI to it and access the data simply.

Example: I have a grid that shows all of the Employees that use the site. However, the column with LastLoginDate exists over in the User Table. I want the dataaccess code to give me an object that I can pass through my controller into my web form to display this information, but I don't need any of the complexity of an object hierarchy or the unbindability of child properties.

Is that a useful suggestion?
0
Alfred Ortega
Top achievements
Rank 2
answered on 08 Dec 2008, 09:51 PM
Joshua,
That's why I want to have the joins done so that you could bind your grid to something like this:

                    var query = from users in scope.Extent<User>()
                                join userdata in scope.Extent<UserData>()
                                on users.UserID equals userdata.UserID
                                select new

                                {
                                    ID = users.ID,
                                    LastName = users.LastName,
                                    FirstName = users.FirstName,
                                    LastLogin = userdata.LastLogin
                                };


Now you have an anonymous class based on a join - no extra classes or views needed.
0
joshuarivers
Top achievements
Rank 2
answered on 08 Dec 2008, 10:05 PM
....which is good. Definitely.

However, you can't pass that projection between layers of your app, can you? Nor can you add extensions to it like:

string Fullname
{
get { return Firstname + Lastname;}
}

Most importantly, you can't tell a gridview to use it as a datatype, so you have to create all of your column definitions by hand, which slows down the UI velocity a lot.

I guess you can hand-build your DTOs and linq into them...but couldn't we just have the wizard do it?
0
Alfred Ortega
Top achievements
Rank 2
answered on 08 Dec 2008, 11:50 PM
I agree that would be great.  Would you like to extend the list out?  Obviously my list is a little biased towards what I need but you have some good ideas.  Telerik ---?
0
Thomas
Telerik team
answered on 10 Dec 2008, 10:50 AM
Hello Alfred & Joshua,

as mentioned before, the UI is not fast bindable to types which are created at runtime. What is coming out of the query is basically a collection of object arrays where each array element is a projected column. The only way to make that easily bindable is to transfer the content into a real field of a non-anonymous class; something similiar is happending with the select new statement. So possibly all you would need is a constructor which does the transferral. When then the user defined projection class is usable in all app layers too.

The question I have when seeing this example is why an explicit join is needed:

          var query = from userdata in scope.Extent<UserData>()
select new
{
ID = userdata.User.ID,
LastName = userdata.User.LastName,
FirstName = userdata.User.FirstName,
LastLogin = userdata.LastLogin
};
This assumes that UserData has a reference to its User via the User property, and by following that reference the join is automatically made.

StartsWith, EndsWith, Contains, ToUpper, ToLower are already supported.
Average, Sum, Min, Max, Count are supported for non-grouping queries.

Kind regards,
Thomas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Alfred Ortega
Top achievements
Rank 2
answered on 10 Dec 2008, 12:33 PM

GROUPING:
I saw that the aggregates where done, but for me they need to have the grouping functionality.  The page shows 3 things:

1) A grid of x records - easily accomplished with Skip/Take

2) Total # of records because we need to set the virtual page count on the grid for custom paging - easily accomplished with Count();
3) For all possible results I need a list of the categories and the amount of times they appear for a tag cloud.  This is where Linq can do it, but OpenAccess can not.  It seems OA can not perform this action via Linq or OQL


JOINS:
I just put the join in there because although it was a natural join LInq supports other join types as well (http://msdn.microsoft.com/en-us/library/bb311040.aspx).  I believe the statement would require a reference to the joined class first though...


          var query = from userdata in scope.Extent<UserData>()
                select new
                {
                  ID = userdata.User.ID,
                  LastName = userdata.User.LastName,
                  FirstName = userdata.User.FirstName,
                  LastLogin = userdata.LoginInfo.LastLogin
                };

-Al

0
joshuarivers
Top achievements
Rank 2
answered on 10 Dec 2008, 07:00 PM
What you're proposing to solve my join issues sounds like it would work.....but it also confuses me totally.

The simple case here isn't so bad, although it's still a shift for me. But what about more complex cases? What about when I have a number of different 'projections' of my data into my object graph. Mapping tables into objects is GREAT. It saves a lot of work right off the top. But working with legacy databases, I definitely find that the objects I want to use join together bits from different tables, and not just in a master-details or parent-collection way. Do I need to build out query groups and the like for each of these 'projections'? What are the performance implications? Does joining three tables together by creating a new class and populating it off the object graph really only only perform a single sql query?

The real frustration is that this stuff ought to be easy. Pick up an "ASP.NET in 20 Minutes" book, and it will show you how to get arbitrary data out of an SQL server and bind it to your UI lickety-split. The problem is that you end up with a horrible program that's not testable or extensible or ....

I would assume that most of what I'm looking for will be supported when Views and Stored Procedures are supported, but we really shouldn't have to modify the DB to do these things. If it can be done from a view or sproc, it should be do-able from arbitrary sql, or Linq. (Or perhaps I have no idea what I'm talking about <grin>)

I'm really excited about OpenAccess, and I'm here because data access in my projects has been like swimming through mud. I'm tired of that. And 10 minutes of working with nHibernate makes me really want...a wizard.
0
Accepted
Dimitar Kapitanov
Telerik team
answered on 12 Dec 2008, 03:37 PM
Hello joshuarivers,
We escalated the priority of having well implemented Grouping functionality inside our LINQ provider library. You can expect the enhancements to be available early next year. And just to clarify, I am not able to give you exact time-frame at the moment.

All the best,
Dimitar Kapitanov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
joshuarivers
Top achievements
Rank 2
answered on 12 Dec 2008, 03:49 PM
Fantastic. You guys are the best!
0
Alfred Ortega
Top achievements
Rank 2
answered on 12 Dec 2008, 03:50 PM
Thank you very much!
0
Himadri Shekhar
Top achievements
Rank 1
answered on 01 Jan 2009, 06:45 AM
I have created a view in my SQL server 2005 database.
I want to access the view through Persistant class.
Is it possible to access a view using ORM?
Please suggest.

Thanks.
0
Thomas
Telerik team
answered on 02 Jan 2009, 10:51 AM
Hello Himadri Shekhar,

this thread was dealing with a different topic.

To answer your question: Currently there is no support for views, but this topic is on our agenda.

Best wishes,
Thomas
Tags
LINQ (LINQ specific questions)
Asked by
Alfred Ortega
Top achievements
Rank 2
Answers by
Thomas
Telerik team
Alfred Ortega
Top achievements
Rank 2
joshuarivers
Top achievements
Rank 2
Peter Brunner
Telerik team
Dimitar Kapitanov
Telerik team
Himadri Shekhar
Top achievements
Rank 1
Share this question
or