Click here to Skip to main content
15,884,739 members
Please Sign up or sign in to vote.
5.00/5 (3 votes)
See more:
I have just started using LINQ to Entities and I am trying to create a dynamic query that will only select partial columns and/or order by different columns dynamically. My background was writing dynamic SQL strings and using the sql client classes. I much prefer writing LINQ to Entities for data access because of the ease of writing it.. Can someone please point me in the proper direction in version 4.5.1 of .NET and version 6 of Entity? I have trouble believing that with this great technology there is no way to specify that I only want certain columns with out writing a different method for each set of columns and or ordering... that makes we want to go back to string strings and ADO. Not looking for someone to write my code just looking for expert advice on the proper pattern to pursue. Thank you

Edit: I have investigated System.Linq.Dynamic but it looks like it has not been updated in a couple of years. I have also looked at the ExpressionBuilder class.. I realize there are a few ways to do it but don't want to start down a path and waste a bunch of time because there is a better way of doing this currently.
Posted
Updated 17-May-14 12:10pm
v2

 
Share this answer
 
Comments
[no name] 24-May-14 15:12pm    
Max. is unfortunately 5
Maciej Los 24-May-14 18:14pm    
;) Thank you, Bruno ;)
You might check out Invent your own Dynamic LINQ parser[^]. I wrote that parser a while ago to create predicates suitable for LINQ-to-Object queries.
Cheers
Andi
 
Share this answer
 
Comments
[no name] 24-May-14 17:52pm    
und dä bringsch erscht jetzta, das kasch nüd mache;) mes tschintg

*lol* _dä_ hät mich wohl verrate, das ich scho länger wäg bin
Maciej Los 24-May-14 18:21pm    
;) In English, please ;)
I have no doubt, that answer deserves the highest praise and i hope you wrote it in your comment.
[no name] 24-May-14 18:30pm    
ok in english I will try (the above is a mixture between german and very view romansh, a very rare spoken language in switzerland): "What the hell you come with this just now? Anyway my 5"


"und dä bringsch erscht jetzta, das kasch nüd mache" == "What the hell you come with this just now"

"mes tschintg" == "Anyway my 5"
Maciej Los 25-May-14 3:42am    
Good one!
My virtual 5!
Andreas Gieriet 25-May-14 15:09pm    
Even my name is a "Romansh" one, I don't speek Romansh :-(. But I could guess the message ;-).
Cheers
Andi

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900