Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

LINQ (language integrated query) is one of the new features provided with VS 2008 and .NET 3.5.  LINQ makes the concept of querying data a first class programming concept in .NET, and enables you to efficiently express queries in your programming language of choice.

One of the benefits of LINQ is that it enables you to write type-safe queries in VB and C#.  This means you get compile-time checking of your LINQ queries, and full intellisense and refactoring support over your code:

While writing type-safe queries is great for most scenarios, there are cases where you want the flexibility to dynamically construct queries on the fly.  For example: you might want to provide business intelligence UI within your application that allows an end-user business analyst to use drop-downs to build and express their own custom queries/views on top of data. 

Traditionally these types of dynamic query scenarios are often handled by concatenating strings together to construct dynamic SQL queries.  Recently a few people have sent me mail asking how to handle these types of scenarios using LINQ.  The below post describes how you can use a Dynamic Query Library provided by the LINQ team to dynamically construct LINQ queries.

Downloading the LINQ Dynamic Query Library

Included on the VS 2008 Samples download page are pointers to VB and C# sample packages that include a cool dynamic query LINQ helper library.  Direct pointers to the dynamic query library (and documentation about it) can be found below:

Both the VB and C# DynamicQuery samples include a source implementation of a helper library that allows you to express LINQ queries using extension methods that take string arguments instead of type-safe language operators.  You can copy/paste either the C# or VB implementations of the DynamicQuery library into your own projects and then use it where appropriate to more dynamically construct LINQ queries based on end-user input.

Simple Dynamic Query Library Example

You can use the DynamicQuery library against any LINQ data provider (including LINQ to SQL, LINQ to Objects, LINQ to XML, LINQ to Entities, LINQ to SharePoint, LINQ to TerraServer, etc).  Instead of using language operators or type-safe lambda extension methods to construct your LINQ queries, the dynamic query library provides you with string based extension methods that you can pass any string expression into.

For example, below is a standard type-safe LINQ to SQL VB query that retrieves data from a Northwind database and displays it in a ASP.NET GridView control:

Using the LINQ DynamicQuery library I could re-write the above query expression instead like so:

 

Notice how the conditional-where clause and sort-orderby clause now take string expressions instead of code expressions.  Because they are late-bound strings I can dynamically construct them.  For example: I could provide UI to an end-user business analyst using my application that enables them to construct queries on their own (including arbitrary conditional clauses).

Dynamic Query Library Documentation

Included with the above VB and C# Dynamic Query samples is some HTML documentation that describes how to use the Dynamic Query Library extension methods in more detail.  It is definitely worth looking at if you want to use the helper library in more depth:

 

Download and Run a Dynamic Query Library Sample

You can download and run basic VB and C# samples I've put together that demonstrate using the Dynamic LINQ library in an ASP.NET web-site that queries the Northwind sample database using LINQ to SQL:

You can use either Visual Web Developer 2008 Express (which is free) or VS 2008 to open and run them.

Other Approaches to Constructing Dynamic LINQ Queries

Using the dynamic query library is pretty simple and easy to use, and is particularly useful in scenarios where queries are completely dynamic and you want to provide end user UI to help build them.

In a future blog post I'll delve further into building dynamic LINQ queries, and discuss other approaches you can use to structure your code using type-safe predicate methods (Joseph and Ben Albahari, authors of the excellent C# 3.0 In a Nutshell book, have a good post on this already here). 

Hope this helps,

Scott

Published Monday, January 07, 2008 11:02 PM by ScottGu
Filed under: , , ,

Comments

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 2:29 AM by Jonatan

That´s nice, but how is it handled in LINQ to SQL? Is it possible to use sqlparameters, or does it prevent SQL injection in some other way in senarios like this:

.Where(String.Format("CategoryID={0}" & Request.QueryString["id"])

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 2:35 AM by Osman Pirci

Thanks Scott, following you up on.

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 2:36 AM by ScottGu

Hi Jonatan,

>>>>>> That´s nice, but how is it handled in LINQ to SQL? Is it possible to use sqlparameters, or does it prevent SQL injection in some other way in senarios like this: .Where(String.Format("CategoryID={0}" & Request.QueryString["id"])

Because LINQ to SQL uses type-safe data model classes, you are protected from SQL Injection attacks by default.  LINQ to SQL will automatically encode the values based on the underlying data type.

BTW - you can use the Where() extension method either like so:

   .Where(String.Format("CategoryID={0}" & Request.QueryString["id"])

Or:

   .Where(String.Format("CategoryID=@0", Request.QueryString["id"])

The second option allows you to specify any parameter markers you want in the query, and then inhect the values as params that you pass separately.

Hope this helps,

Scott

# Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 2:38 AM by DotNetKicks.com

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 2:46 AM by LukCAD

Thank you Scott!

I download the C# Dynamic Query Library you gave. I found nice example of Dlinq into path CSharpSamples\LinqSamples\DynamicQuery\DynamicQuery and then I found nice 101 examples into this path CSharpSamples\LinqSamples\SampleQueries about Linq at all. Just run it by VS2008 Express i had all examples by different implementation of linq, like:

- Linq To Sql

- Linq to XML

- Linq over DataSet

- XQury use cases

Great!

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 3:43 AM by Mike

Great! So why is this a zip somewhere on MSDN that has a code file we need to compile? If this works as good as you say it does, please consider putting it in the Extensions release.

Thanks!

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 3:52 AM by FransBouma

erm...

"One of the benefits of LINQ is that it enables you to write type-safe queries in VB and C#. "

and then you come with an example which precisely kills this benefit.

Why not use the example of concatenate Linq queries? (where you use one linq query in another one, which will be combined into 1 expression tree at runtime by the provider?)

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 3:54 AM by Ben Hall

Interesting stuff!! I'll have a closer look later.

Is this new? Or has it been around for a while and I just haven't noticed.

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 3:54 AM by ScottGu

Hi Frans,

>>>>>> Why not use the example of concatenate Linq queries? (where you use one linq query in another one, which will be combined into 1 expression tree at runtime by the provider?)

As I said at the end of this post, my next dynamic linq post will cover using predicate methods to compose LINQ queries.  This enables type-safe expression composition.

Thanks,

Scott

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 3:55 AM by ScottGu

Hi Ben,

>>>>>>> Interesting stuff!! I'll have a closer look later. Is this new? Or has it been around for a while and I just haven't noticed.

Believe it or not it has been around awhile. :-)  I believe it shipped in the samples in Beta2.

Thanks,

Scott

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 4:07 AM by Ian Cooper

Hi Scott,

For interest I posted something on using the predicate approach, via the specification pattern back in August on my old blog: iancooper.spaces.live.com/.../cns!844BD2811F9ABE9C!451.entry

I'll probably update for the release version of LINQ at some point this month on the new blog as part of the series there on architecting LINQ applications.

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 4:13 AM by Steve400

Hey Scott,

Another great post.  How's Part 5 of the MVC Series coming?

Thanks,

--Steve

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 5:00 AM by Stefan Cruysberghs

Yesterday I published an article about dynamic Where- and OrderBy-clauses in LINQ to SQL. It covers function delegates, expression trees and the PredicateBuilder class from Joseph Albahari.

www.scip.be/index.php

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 5:07 AM by Igor

Interesting! Coding with LINQ Dynamic Query Library looks very similar to SubSonic ...

Thank you! I will spend some time on it.

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 5:15 AM by fight4it

Using this removes the real time compiler checking for the syntax, isn't it?

It looks more like Subsonic query or Nhibernate hql......

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 5:41 AM by Kris Mac

Is it possible to combine a strongly typed Linq expression with a dynamic query?

For example, create your base query:

var query = from p in Northwind.Products

where p.CategoryID = 2

select p

and then append a dynamic order by to the query, something like

query.OrderBy = "SupplierId"

I prefer to use the strongly typed approach but as you said, not all scenarios allow this (Custom sorting in particular) in which case it would be nice to still do the bulk of your Linq in a strongly typed manor

# Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library) - ScottGu’s Blog « Noocyte’s Weblog

Pingback from  Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library) - ScottGu’s Blog « Noocyte’s Weblog

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 6:26 AM by Kevin Daly

Any Silverlight 2.0 posts in the works?

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 6:56 AM by Juan María

Hi Scott:

You can read this post in spanish here:

thinkingindotnet.wordpress.com/.../dynamic-linqparte-1-usando-la-libreria-de-linq-dynamic

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 7:14 AM by Sambo

Good things,

Type-safe and prevent SQL injection.

I am looking at for your next post.

Thanks,

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 8:13 AM by Felix

Hi Scott,

great I have been waiting for that. Thanks for posting. I look forward for the followups. This might be some sort of-topic. But are you posting about LINQ to SQL and many-to-many relations. How to handel it with LinqDatasource Insert/Update, etc? Or do I have to code this manually and extend my DataContext. Maybe you posted already about that and I am only missing something...

Anyway thanks for sharing the information...

Regards

Felix

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 9:03 AM by ccatto

Hey Now Scott,

The library's sure are a great resource.

Thx,

Catto

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 9:52 AM by Scott

I have been playing with the Dynamic Query Library for a while now. However, I never could figure out a way to do joins, using this library.

Thanks,

Scott

# Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library) - ScottGu’s Blog » article » Thats The New Thing!

Pingback from  Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library) - ScottGu’s Blog » article » Thats The New Thing!

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 10:10 AM by B

What about a scenario where we let our users add their own custom columns to a table (SQL).  Can we use Linq to query a table that has changed?  Is there some kind of “Refresh” or something of that sort?

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 10:36 AM by Matt Warren

Scott, I think you meant to have the arguments w/o the call to String.Format like this:

.Where("CategoryID=@0", Request.QueryString["id"])

Using String.Format is just a fancier way to concatenate strings and its use can still lead to string injection attacks.  

For example:  .Where(String.Format("CategoryID={0}", "'X' OR Secrets=1"))

When you use the Dynamic API with the '@' parameters and specify arguments directly the two are never concatenated together so your arguments are kept isolated all the way through.  A text variables contents will never be misinterpreted as part of the query.

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 12:03 PM by Ferdinand Swaters

Hi Scott,

Linq is realy great, for me the best thing since Object Oriented Programming (realy!). However, this move i can't follow. Everything you are doing here (and _much_ more) can be done if you have combinable expressions. And that is not hard to implement. So why do you want us to return to the dark ages of glueing strings together to build a query, where you could have a fully typesafe intellisensable solution that would look like:

   if (!String.NullOrEmpty(catselect)) {

        var oldwhereclause=whereclause;

        whereclause = p => oldwhereclause(p) && p.Category.CATEGORYNAME==catselect;

   }

   var q =

       from p in ...

            .Where(whereclause) // don't realy like this syntax here but it works..

Note that not only my where clause is now constructed typesafe, also the tables needed for the query are changed, which would be troublesome is a string-glueing aproach.

Cheers, Ferdinand Swaters (still on 2008 Beta 2)

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 1:00 PM by Shloma Baum

Scott,

Sometime ago you mentioned about doing a post on how to use LINQ in a multi-tier enviroment, I would love to get into LINQ but can't see on how this could work. Would very much appreciate if you could comment on that.

Thanks in advance

Shloma

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 1:17 PM by Roger Jennings

Pingback from oakleafblog.blogspot.com/.../linq-and-entity-framework-posts-for.html.

Thanks for this addition, too:

BTW - you can use the Where() extension method either like so:

  .Where(String.Format("CategoryID={0}" & Request.QueryString["id"])

Or:

  .Where(String.Format("CategoryID=@0", Request.QueryString["id"])

The second option allows you to specify any parameter markers you want in the query, and then inhect the values as params that you pass separately.

--rj

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 4:04 PM by Ian Cooper

Hmm try this the link comes out better. It's the overview from my latest series on LINQ codebetter.com/.../architecting-linq-to-sql-applications-part-4.aspx

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 4:17 PM by Trent Lange

Thanks Scott!

Is it possible to get the following behavior with this library (Like statement "%")?  I am having trouble getting it to work.

Dim _Course = From p In University.Courses _

             Where p.Course_Name.StartsWith("B") _

             Select p

# Inferis’ Mind Dump » Blog Archive » links for 2008-01-08

Pingback from  Inferis’ Mind Dump  » Blog Archive   » links for 2008-01-08

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 6:06 PM by KK

Is LINQ to SQL suitable for multi-tier apps?  I've read on various sites that LINQ to SQL lacks mulit-tier capabilities.  Is this true?  Are you still planning a blog to cover multi-tier using LINQ to SQL?

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 6:43 PM by Andrew

Hi Scott,

Great stuff, but isn't the example dynamic query library already included in System.Web.Query.Dynamic? Any idea why the classes in that namespace are not public?

Thanks,

Andrew

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 7:27 PM by liuyun

I don't think your Dynamic LINQ is very good.I think we can use lambda tree to create dynamic LINQ better.

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 9:07 PM by HongChao Wang

Hi Scott, welcome to China. :)

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 9:18 PM by ghj1976

Welcome to China. :) :) :) :) :) :)

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 9:55 PM by lc

HI man,welcome to china!

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 08, 2008 10:25 PM by Ariel

Welcome to China ;-)

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 12:16 AM by heason zhu

Welcome to China.

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 12:16 AM by William Stacey

What would be sweet is some kind of Predicate textbox that would do Intellisense for the user by understanding the parms, types and operators the dev "sets" for the textbox.  

# Link Listing - January 8, 2008

Wednesday, January 09, 2008 12:25 AM by Christopher Steen

ASP.NET Web Development Toolbox [Via: Chris Brandsma ] WPF WPF/Xaml Web News - 2008/01/08 [Via: rrelyea...

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 2:48 AM by ScottGu

Hi Stefan,

>>>>>> Yesterday I published an article about dynamic Where- and OrderBy-clauses in LINQ to SQL.

That is a great article.  Pointing others at it in case they missed it: www.scip.be/index.php

Thanks,

Scott

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 2:49 AM by ScottGu

Hi Kris,

>>>>>>> Is it possible to combine a strongly typed Linq expression with a dynamic query?

Yes - you can mix both strongly typed queries and the dynamic string based queries together, which is quite nice and useful.

Thanks,

Scott

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 2:49 AM by ScottGu

Hi Kevin,

>>>>>>> Any Silverlight 2.0 posts in the works?

Yep - I am just getting ready to start posting heavily on Silverlight 2.0. :-)

Thanks,

Scott

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 2:51 AM by ScottGu

Hi Felix,

>>>>>> great I have been waiting for that. Thanks for posting. I look forward for the followups. This might be some sort of-topic. But are you posting about LINQ to SQL and many-to-many relations. How to handel it with LinqDatasource Insert/Update, etc? Or do I have to code this manually and extend my DataContext. Maybe you posted already about that and I am only missing something...

I haven't posted on M:M relationships yet.  Here is a blog post that discusses it a little though: blogs.msdn.com/.../how-to-implement-a-many-to-many-relationship-using-linq-to-sql.aspx

Hope this helps,

Scott

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 2:52 AM by ScottGu

Hi Ferdinand,

>>>>>>> Linq is realy great, for me the best thing since Object Oriented Programming (realy!). However, this move i can't follow. Everything you are doing here (and _much_ more) can be done if you have combinable expressions

This post is part 1 of 2.  In the second part I'm going to discuss using combined expressions and predicate builders to do type-safe query composition.

Thanks,

Scott

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 2:53 AM by ScottGu

Hi Shloma,

>>>>>>> Sometime ago you mentioned about doing a post on how to use LINQ in a multi-tier enviroment, I would love to get into LINQ but can't see on how this could work. Would very much appreciate if you could comment on that.

I still need to write a post on this with LINQ to SQL.  It is on my list of things to-do (unfortunately it is a big list though!).

Sorry!

Scott

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 2:55 AM by ScottGu

Hi Trent,

>>>>>>> Is it possible to get the following behavior with this library (Like statement "%")?  I am having trouble getting it to work.

You can use .StartsWith(), .EndsWith() and .Contains() to get functionality similar to the like statement with SQL.

Hope this helps,

Scott

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 2:57 AM by ScottGu

Hi Andrew,

>>>>>>> Great stuff, but isn't the example dynamic query library already included in System.Web.Query.Dynamic? Any idea why the classes in that namespace are not public?

Yep - this functionality is included for the LinqDataSource control in ASP.NET.  Unfortunately the LINQ team didn't have time to fully design the dynamicquery library to the extent they felt comfortable shipping it as a broadly generic library in the framework with .NET 3.5 - which is why it is currently shipped as a source sample.  

Hope this helps,

Scott

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 4:29 AM by ian

Welcome to China

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 6:05 AM by Simon

Good article Scott, as always.

I've been looking at using the CLR in SQL Server to get round problems with dynamic queries in stored procedures. I haven't seen much on the use of LINQ within SQL Server itself. Are you aware of any problems and would I be able to use the Dynamic Query Library there as well?

Thanks, Simon

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 9:37 AM by Shloma Baum

Thanks Scott!

Maybe I could bribe you with something to push this one up the list a bit :)...

Anyway your posts are very much welcome, I love your writing style and to-the-point approach!

Enjoy

Shloma

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 11:15 AM by mehfuzh

Thanks Scott, really nice post!!

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 09, 2008 1:16 PM by Partha

In your code what is NorthwindDataContext?

# Random Reading: F#, Linq, ToyScript « Tales from a Trading Desk

Pingback from  Random Reading: F#, Linq, ToyScript « Tales from a Trading Desk

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Thursday, January 10, 2008 4:22 AM by Roger Hendriks

Impressive! This is far more easier dan lambda expressions to build complex and/or search queries. The only thing holding me from dropping Gentle and using Linq all the way is Oracle support. I hope Core Lab, OpenLink, DataDirect or Oracle will support Linq to Sql soon (without having to use the Entity Framework :). Do you have some info about this?

By the way, for those lambda fans: www.albahari.com/.../predicatebuilder.html

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Thursday, January 10, 2008 12:11 PM by Ryan

I really like where you are going with these examples Scott. I've been looking through some of the LINQ documentation and I find changes in the way people are accessing the data in their DataContext. Sometimes they use something like 'from n in src.records' and sometimes they use 'src.records.select'. I was wondering what the real difference is in the two and what the trade offs of using either would be?

I made my own little example of some timing to see which would be faster for a simple select. I am consistently finding that the 'from n in src.records' is much faster than the other type.

///////////////////////

// Code Snippet

//////////////////////

[DllImport("kernel32.dll")]

extern static short QueryPerformanceCounter(ref long x);

[DllImport("kernel32.dll")]

extern static short QueryPerformanceFrequency(ref long x);

long start2 = 0, end2 = 0;

QueryPerformanceCounter(ref start2); // start timer

var visitors2 = from v in SrcContext.visitors where v.active == true select v;

QueryPerformanceCounter(ref end2); // end timer

long start1 = 0, end1 = 0;

QueryPerformanceCounter(ref start1); // start timer

var visitors1 = SrcContext.visitors.Select(c => c.active == true);

QueryPerformanceCounter(ref end1); // end timer

// retrieve frequency

long freq = 0;

QueryPerformanceFrequency(ref freq);

double total1 = (end1 - start1) * 1.0 / freq;

double total2 = (end2 - start2) * 1.0 / freq;

////////////////

// End

////////////////

# CodeDom extensions and dynamic LINQ (string/script to LINQ emitting) « Igor’s Weblog

Pingback from  CodeDom extensions and dynamic LINQ (string/script to LINQ emitting) « Igor’s Weblog

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Friday, January 11, 2008 1:23 PM by Evert Wiesenekker

Has anybody tried it on DataTables? I tried it, but I think I did something wrong or it is not supported.

Thanks for any help!

Evert

# 動的 LINQ (パート 1: LINQ 動的クエリライブラリの使用)

Sunday, January 13, 2008 12:28 AM by Chica's Blog

動的 LINQ (パート 1: LINQ 動的クエリライブラリの使用)

# Weekly Link Post 24 « Rhonda Tipton’s WebLog

Sunday, January 13, 2008 6:23 PM by Weekly Link Post 24 « Rhonda Tipton’s WebLog

Pingback from  Weekly Link Post 24 « Rhonda Tipton’s WebLog

# .NET Framework 3.5 RTM « C:\>dir *.*

Monday, January 14, 2008 12:31 AM by .NET Framework 3.5 RTM « C:\>dir *.*

Pingback from  .NET Framework 3.5 RTM « C:\>dir *.*

# Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library) | DavideZordan.net

Pingback from  Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library) | DavideZordan.net

# Resumo da semana - 14/01/2008

Monday, January 14, 2008 5:55 PM by Console.Write(this.Opinion)

Resumo da semana - 14/01/2008

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, January 16, 2008 9:51 PM by MW

Does anyone have any examples of how to use the dynamic query on XML instead of SQL? It would be great if there is an example of how to apply an orderby and allocate the type of the orderby dynamically as well with the source being XML.

# Linq

Wednesday, January 23, 2008 2:10 AM by BillKill77

ScottGu nous parle de LINQ et des requêtes dynamiques, affaire à suivre...

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Friday, January 25, 2008 5:01 AM by Paymon Khamooshi

Hi Scott,

This is great. I'm glad you've done it, you saved me from updating my dynamic querying library to work with Linq.

I can't find the namespace of those extension methods though, whey do they live?

Paymon

# LINQ Dinámico

Sunday, January 27, 2008 1:02 PM by La capa de datos

En principio, la tecnología LINQ nos permite hacer cosas bastante interesantes para recolectar objetos

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Monday, January 28, 2008 10:30 AM by Smit Shah

Dim values = From t1 In MyTables.Table1 _

JOIN t2 In MyTables.Table2 On t1.ID Equals t2.ID

Select t1, t2

How do I dynamically order this query ??

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 29, 2008 10:11 AM by tom.vangaever

"Operator '==' incompatible with operand types 'Guid?' and 'Guid'"

what am i doing wrong here?

Guid? SiteID = ((COM_Site)(cmbSectiesDynamic.SelectedItem)).ID;

List<Employee> employeeList = this.m_databaseContext.Employees.Where("SiteID ==@0",SiteID).ToList();

i don't get it..

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Tuesday, January 29, 2008 10:16 AM by tom.vangaever

@Paymon

You need to copy paste the Dynamic.cs class into your project.

You can find this class in the examples or here:

tomvangaever.be/.../Dynamic.cs

when you add this class to your solution you can enter:

using System.Linq.Dynamic;

and there you go :)

Does anyone know why this nullable Guid doesn't want to work...?

.Tom

# Dynamic LINQ o como construir consultas dinámicas con LINQ!

Tuesday, January 29, 2008 11:35 AM by Blog del CIIN

Una de las preguntas m&#225;s t&#237;picas que surgen cuando he impartido alg&#250;n seminario en el

# log.itto.be &raquo; Blog Archive &raquo; links for 2008-01-30

Wednesday, January 30, 2008 9:19 AM by log.itto.be » Blog Archive » links for 2008-01-30

Pingback from  log.itto.be  &raquo; Blog Archive   &raquo; links for 2008-01-30

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Thursday, January 31, 2008 2:43 AM by Kris

Tom - the "Operator '==' incompatible with operand types 'Guid?' and 'Guid'" issue looks like a bug in System.Linq.Dynamic.

See this thread: forums.microsoft.com/.../ShowPost.aspx

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Sunday, February 03, 2008 8:12 AM by Dave

I'm not totally sure if this is a good thing. The great benefit of the 'old' linq is the fact that's it's strong typed. In the early .net days we had typed datasets which is replaced with the much better Linq to Sql. Linq is already providing joining, grouping and filtering.

I can already do: db.Products.Where(p => p.Category.CategoryName == "Beverages");

In a production environment 'dynamic' queries don't exist. because all queries are constructed based on contextual arguments. There's nothing dynamic about  categoryid (which in your example is filtered on the value '2'). It's not like if I suddenly pass an url parameter SupplierID=5 that's it's included in the query.

So all query are predetermined. My example can easily changed into db.Products.Where(p => p.Category.CategoryID == Request.QueryString("CatID"));. Using the MVC web application CatID is even processed by controller and passed as a strong (validated) parameter to the data layer (Models).

Back in the classic ASP days late binding was normal. These days we use strong typed code so the compiler can warn us about any typo's we might have made. Very important for beginning programmers.

And even linq itself can be used to 'dynamicly' construct a query. Let's say a admin user want to filter the product list. The UI provides him (even better her ;-) which the dropdowns for category, supplier and a textbox for entering  minimum unitprice. Most databases only use positive ID's for primary keys, so a returned (form) value of -1 means no selection has been made. UnitPrice has been defined as double? (nullable)

var products =northwind.Products; //just initializing the quey

if (categoryId > -1)

products.Where(p => p.Category.CategoryID == categoryId);

if (supplierId > -1)

products.Where(p => p.Supplier.SupplierID == supplierId);

if (unitPrice != null)

products.Where(p => p.UnitPrice >= unitPrice);

DataGrid.DataSource = products;

DataGrid.DataBind(); //Database query is performed here

'Dynamic' queries will usually be build in a similar way, except products would than be a string. A string which easily can contains typo's, assiging a number to a text field. Those issues present them selfs only at runtime.

So again, what's the benefit of using late-bind, non-typed data queries? It's almost like I'm back in the classic ASP days. Like you said, you can rewrite a strong-typed linq query into a late-bind query. But I don't see the point of doing that.

Maybe you presented me a 'wrong' example of using dynamic linq queries, but for now I only see down sides.

# Linq GroupByMany dynamically

Wednesday, February 06, 2008 6:04 PM by Mitsu's blog

Shawn asked me in my last post about GroupByMany how to use it dynamically. The answer is not easy. So

# MSDN Blog Postings &raquo; Linq GroupByMany dynamically

Wednesday, February 06, 2008 8:39 PM by MSDN Blog Postings » Linq GroupByMany dynamically

Pingback from  MSDN Blog Postings  &raquo; Linq GroupByMany dynamically

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Thursday, February 07, 2008 2:50 AM by Stanislav Fritz

Can one dynamically assign a TABLE name at run time? e.g.

               var query = from c in db.stringVariableHoldingTableName

I know the above WON'T work, but it illustrates (I think) what I am trying to accomplish.

I have tables the have information about the other tables, that allow me to change the behavior of the program (in some respects) by changing the database/tables ... but this only works if I can do the table name on the fly.

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Saturday, February 09, 2008 8:29 PM by Stephen

How can you handle null values with the LINQ data source control? For example I have a drop down list that controls the data displayed in a gridview.  

<asp:DropDownList ID="drpdwnlstCategory" runat="server" DataSourceID="lnqdsCategories" AppendDataBoundItems="True" AutoPostBack="True" DataTextField="categoryName" DataValueField="categoryId"><asp:ListItem></asp:ListItem></asp:DropDownList>

<asp:LinqDataSource ID="lnqdsItems" runat="server"

ContextTypeName="MyWebDataContext"

Select="new (itemId, categoryId, itemName, itemDescription, itemPrice, storeName, notes, serialNumber, modelNumber, brandName, purchaseDate, tblItemCategory.categoryName)"

TableName="tblHouseInventories"

Where="categoryId.ToString() = @categoryId" >

<WhereParameters>

  <asp:ControlParameter ControlID="drpdwnlstCategory" Name="categoryId" PropertyName="SelectedValue" Type="String" />

</WhereParameters>

</asp:LinqDataSource>

With the SQL datasource, I could use "categoryId=@categoryId OR @categoryId IS NULL" as my WHERE clause so that I could show all records when the "blank" item was selected from the drop down or only the specified item category if one was selected.

With the LINQ datasouce I can't get this to work. If I specifiy "AutoGenerateWhereClause=true" it works when the "blank" item is selected but does not work for the other categories because my categoryId is a GUID. If I specify my own WHERE clause as "categoryId.ToString() = @categoryId" it works fine for everything but the "blank" item.

Is it poor design on my part or I am missing something with LINQ?

# Embed code in XAML &laquo; C# Disciples

Sunday, February 10, 2008 6:06 PM by Embed code in XAML « C# Disciples

Pingback from  Embed code in XAML &laquo; C# Disciples

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Sunday, February 10, 2008 6:28 PM by Marlon Grech

Hi,

I used the Dynamic Query API in order to embed code in XAML... Have a look...

marlongrech.wordpress.com/.../embed-code-in-xaml

Great JOB you guys!!!!!

Regards

# Filtering CollectionViewSource Dynamically &laquo; C# Disciples

Monday, February 11, 2008 7:10 AM by Filtering CollectionViewSource Dynamically « C# Disciples

Pingback from  Filtering CollectionViewSource Dynamically &laquo; C# Disciples

# IEnumerable Tales: Compilazione dinamica di query LINQ

Wednesday, February 13, 2008 6:40 PM by di .NET e di altre Amenit

IEnumerable Tales: Compilazione dinamica di query LINQ

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Wednesday, February 20, 2008 5:28 AM by snowwaft

Hi scott

sometimes i want to search the database like this:

var query=from p in db.Customers

   where p.City.Contains("Lon");

but,if i change this expression to dynamic linq expression?

var query=db.Customers.Where("City like @0","Lon"); This dosn't work.

# re: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

Monday, February 25, 2008 10:57 AM by Andy

I find it annyoing that you can't "refresh" a table block in the Linq to SQL designer window. I mean if I change a field in the DB, then I would like to be able to get that change into the designer.  Now I hat do delete the table and then add it again.

# Zend Framework IT &raquo; Zend Framework e Google Summer of Code 2008

Pingback from  Zend Framework IT  &raquo; Zend Framework e Google Summer of Code 2008

# Pages tagged "dynamic"

Wednesday, March 12, 2008 10:46 PM by Pages tagged "dynamic"

Pingback from  Pages tagged "dynamic"

# Dynamic LINQ Queries - TehWorld Blog

Sunday, March 16, 2008 5:58 PM by Dynamic LINQ Queries - TehWorld Blog

Pingback from  Dynamic LINQ Queries -  TehWorld Blog

# LINQ To SQL

Wednesday, March 26, 2008 8:32 AM by Jesse Liberty - Silverlight Geek

A number of folk have written to me in response to my 3rd tutorial asking that I spend some time focusing

# Steve&#8217;s Coding Blog &raquo; Blog Archive &raquo; VB Dynamic Query Library woes

Pingback from  Steve&#8217;s Coding Blog  &raquo; Blog Archive   &raquo; VB Dynamic Query Library woes

# LINQ To SQL

Thursday, April 03, 2008 7:50 PM by Microsoft Silverlight content

A number of folk have written to me in response to my 3rd tutorial asking that I spend some time focusing

# LINQ To SQL

Thursday, April 03, 2008 8:18 PM by Mirrored Blogs

A number of folk have written to me in response to my 3rd tutorial asking that I spend some time focusing

# MoQ Mocks - Use virtual method or interfaces? &laquo; Ramblings of the Sleepy&#8230;

Pingback from  MoQ Mocks - Use virtual method or interfaces? &laquo; Ramblings of the Sleepy&#8230;

# LINQ To SQL : Dynamically Adding a Shared OrderBy Clause

Monday, May 12, 2008 11:25 AM by Hilton Giesenow's Jumbled Mind

One of the features of LINQ queries is Deferred Execution, which Charlie Calvert discusses here with

# Linq GroupByMany - English Version - Community Server

Pingback from  Linq GroupByMany - English Version - Community Server

# Library &raquo; Blog Archive &raquo; Linq GroupByMany - English Version - Community Server

Pingback from  Library  &raquo; Blog Archive   &raquo; Linq GroupByMany - English Version - Community Server

# How to more then solve SilverLight DataGrid issue with anonymous types &raquo; Lab49 Blog

Pingback from  How to more then solve SilverLight DataGrid issue with anonymous types &raquo; Lab49 Blog

# Using Dynamic LINQ for Sorting

Tuesday, June 03, 2008 6:17 PM by Brian Mains Blog

I found this a while ago about using dynamic LINQ in your code. This really works well with the ASP.NET

# Dynamic LINQ != Headache &laquo; Not Just Another Developer

Friday, June 06, 2008 11:42 AM by Dynamic LINQ != Headache « Not Just Another Developer

Pingback from  Dynamic LINQ != Headache &laquo; Not Just Another Developer

# LINQ through PowerShell

Saturday, June 07, 2008 11:44 PM by B# .NET Blog

In a reaction to my post on LINQ to MSI yesterday, Hal wrote this: I don&#39;t know enough about the

# LINQ, “orderby” and dynamic query sample

Saturday, June 14, 2008 5:23 PM by Damir Dobric Posts

One of important benefits of LINQ is that it enables you to write type-safe queries in VB and C#. Unfortunately

# Designing an airline passenger reservation system &raquo; Blog Archive &raquo; Application Architecture - Part 2 - Data Access Layer - Dynamic Linq

Pingback from  Designing an airline passenger reservation system  &raquo; Blog Archive   &raquo; Application Architecture - Part 2 - Data Access Layer - Dynamic Linq

# Archive &raquo; Designing an airline passenger reservation system ?? Blog Archive &#8230;

Pingback from  Archive &raquo; Designing an airline passenger reservation system ?? Blog Archive &#8230;

# Maximum performance using Telerik RadGrid client-side data-binding with LINQ to SQL

Thursday, July 17, 2008 4:30 AM by Vladimir Enchev

Pingback from: blogs.telerik.com/.../maximum_performance_using_telerik_radgrid_client-side_data-binding_with_linq_to_sql.aspx

# LinQ to SQL takes dynamic cretira &laquo; maonet technotes

Thursday, July 17, 2008 12:05 PM by LinQ to SQL takes dynamic cretira « maonet technotes

Pingback from  LinQ to SQL takes dynamic cretira &laquo; maonet technotes

# Maximum performance using Telerik RadGrid client-side data-binding with LINQ to SQL

Friday, July 18, 2008 7:00 AM by Readed By Wrocław NUG members

As I mentioned in one of my previous posts with RadGrid for ASP.NET AJAX Q2 2008 you can access the grid

# Didrex without a prescription.

Thursday, July 31, 2008 4:23 AM by Didrex.

Order didrex adderall no prescription.

# VB 2008 Language Deep Dive - Presentation Materials (Jonathan Aneja)

Thursday, August 21, 2008 1:03 AM by The Visual Basic Team

Last week I got the chance to visit the Toronto .NET User Group and give a talk on all the great new

# RadTips, Episode 4: Client-Side Filtering in the RadGrid

Saturday, August 23, 2008 7:28 PM by Readed By Wrocław NUG members

I am pleased to bring you another exciting episode of RadTips. In this episode, I show how to enable

# Client-Side Data Binding in the RadGrid

Wednesday, August 27, 2008 9:35 AM by Readed By Wrocław NUG members

Over the past several weeks I started a new video series, called RadTips , which demonstrates how to

# Query dinamiche con LINQ

Tuesday, October 21, 2008 7:42 AM by Around and About .NET World

Query dinamiche con LINQ

# Query dinamiche con LINQ

Tuesday, October 21, 2008 7:53 AM by Around and About .NET World

Utilizzando LINQ possiamo creare facilmente comandi per interrogare basi di dati SQL direttamente da

# Scary Halloween &raquo; Blog Archive &raquo; Scary Halloween ?? Blog Archive ?? Halloween Ideas Blog ?? Blog &#8230;

Pingback from  Scary Halloween  &raquo; Blog Archive   &raquo; Scary Halloween ?? Blog Archive ?? Halloween Ideas Blog ?? Blog &#8230;

# Dynamic Linq expression generator

Wednesday, November 19, 2008 4:32 AM by Dynamic Linq expression generator

Pingback from  Dynamic Linq expression generator

# .NET @ Kape Ni LaTtEX &raquo; Blog Archive &raquo; Combining generic predicates in C#

Pingback from  .NET @ Kape Ni LaTtEX  &raquo; Blog Archive   &raquo; Combining generic predicates in C#

# Aaron Lerch &raquo; Blog Archive &raquo; Case insensitive string comparisons with LINQ Dynamic Query

Pingback from  Aaron Lerch  &raquo; Blog Archive   &raquo; Case insensitive string comparisons with LINQ Dynamic Query

# LINQ Dynamic Query Library &laquo; vincenthome&#8217;s Tech Clips

Monday, December 15, 2008 3:18 PM by LINQ Dynamic Query Library « vincenthome’s Tech Clips

Pingback from  LINQ Dynamic Query Library &laquo; vincenthome&#8217;s Tech Clips

# Dynamically Composing LINQ OrderBy Clauses &laquo; Critical Development

Pingback from  Dynamically Composing LINQ OrderBy Clauses &laquo; Critical Development

# Where Clause in Linq &laquo; A Lost Boy&#8217;s Blog

Tuesday, January 06, 2009 8:32 AM by Where Clause in Linq « A Lost Boy’s Blog

Pingback from  Where Clause in Linq &laquo; A Lost Boy&#8217;s Blog

# seiti.eti.br &raquo; Blog Archive &raquo; ComponentArt Grid, ServerTemplate e Linq to SQL

Pingback from  seiti.eti.br  &raquo; Blog Archive   &raquo; ComponentArt Grid, ServerTemplate e Linq to SQL

# Dynamic Expressions Example &laquo; Angel &#8220;Java&#8221; Lopez on Blog

Pingback from  Dynamic Expressions Example &laquo; Angel &#8220;Java&#8221; Lopez on Blog

# Un ejemplo de Dynamic Expressions

Saturday, January 31, 2009 4:01 AM by Angel "Java" Lopez

El jueves, estaba preparando una presentación para ayer viernes, explicando cálculo lambda, su historia

# Un ejemplo de Dynamic Expressions | Buanzolandia

Saturday, January 31, 2009 6:02 PM by Un ejemplo de Dynamic Expressions | Buanzolandia

Pingback from  Un ejemplo de Dynamic Expressions | Buanzolandia

# Combining generic predicates in C#

Monday, February 02, 2009 11:53 AM by Drinking .NET with LaTtEX

I&#39;ve got a requirement wherein I needed to have a way to make dynamic predicates, with the need to

# Dynamic Expressions in LINQ to Entities &mdash; The Grubbsian

Wednesday, February 11, 2009 2:38 PM by Dynamic Expressions in LINQ to Entities — The Grubbsian

Pingback from  Dynamic Expressions in LINQ to Entities &mdash; The Grubbsian

# Does LINQ StinQ? Not with PLINQO! &laquo; Technimusings

Wednesday, February 18, 2009 4:53 PM by Does LINQ StinQ? Not with PLINQO! « Technimusings

Pingback from  Does LINQ StinQ?  Not with PLINQO! &laquo; Technimusings

# 转:动态LINQ的几种方法

Wednesday, February 18, 2009 9:10 PM by Sammy

来自:www.yaosansi.com/.../1382.html

在使用LINQ中,会发现使用很多传统的多条件查询很难实现。

这里提供网上已有的几种方法:

一、用表达式树依据...

# Dynamic OrderBy in LINQ

Thursday, February 19, 2009 4:00 PM by Stuart Thompson's Blog

Dynamic OrderBy in LINQ

# Dynamic Expressions with LINQ to Entities &mdash; The Grubbsian

Pingback from  Dynamic Expressions with LINQ to Entities &mdash; The Grubbsian

# Reduce PropertyGrid development pain by using LINQ Dynamic Expressions

Monday, March 02, 2009 3:37 AM by Howard van Rooijen's Blog

As I mentioned in my last post I've been working with Microsoft Blueprints , one of the problems I encountered

# 动态LINQ (第一部分:使用LINQ动态查询库)

Tuesday, March 03, 2009 11:18 AM by bitstudio

动态LINQ(第一部分:使用LINQ动态查询库)

【原文地址】DynamicLINQ(Part1:UsingtheLINQDynamicQueryLibrary)

【原文发...

# Hacking into the Windows Workflow Rules Engine

Saturday, March 14, 2009 2:07 AM by beaucrawford.net

Hacking into the Windows Workflow Rules Engine

# Using jQuery Grid With ASP.NET MVC

Tuesday, April 14, 2009 7:37 PM by you've been HAACKED

Using jQuery Grid With ASP.NET MVC

# ASP.NET MVC Archived Blog Posts, Page 1

Wednesday, April 15, 2009 2:19 AM by ASP.NET MVC Archived Blog Posts, Page 1

Pingback from  ASP.NET MVC Archived Blog Posts, Page 1

# Summaries 15.04.2009 &laquo; Bogdan Brinzarea&#8217;s blog

Wednesday, April 15, 2009 5:01 AM by Summaries 15.04.2009 « Bogdan Brinzarea’s blog

Pingback from  Summaries 15.04.2009 &laquo; Bogdan Brinzarea&#8217;s blog

# sachabarber.net &raquo; WPF : Dynamic Search Driven List Results

Pingback from  sachabarber.net  &raquo; WPF : Dynamic Search Driven List Results

# ExpressionEval Two - the lambda case

Tuesday, April 28, 2009 9:44 AM by Vlko napísal ...

Zdrojové kódy: vlko.zilina.net/.../ExpressionEval.zip Intermezzo Zaregistrovaním ExpressionEval

# JQuery Grid Plugin com ASP.NET MVC

Thursday, May 07, 2009 6:54 PM by Daniel Fonseca Castro

JQuery Grid Plugin com ASP.NET MVC

# Simple way to use LINQ with SharePoint ItemCollections

Saturday, May 23, 2009 7:29 AM by Chaks' Corner

Simple way to use LINQ with SharePoint ItemCollections

# Joe Stevens&#039; Blog &raquo; Blog Archive &raquo; Linq to SQL &#8211; ObjectDataSource binding withing paging and sorting

Pingback from  Joe Stevens&#039; Blog  &raquo; Blog Archive   &raquo; Linq to SQL &#8211; ObjectDataSource binding withing paging and sorting

# Blog: Sukru Alatas &raquo; Dynamic Linq sorgular??nda Relation

Wednesday, July 22, 2009 3:41 PM by Blog: Sukru Alatas » Dynamic Linq sorgular??nda Relation

Pingback from  Blog: Sukru Alatas &raquo; Dynamic Linq sorgular??nda Relation

# LINQ to SQL实战 动态LINQ的几种方法

Monday, September 28, 2009 10:53 PM by 剑飘红

在使用LINQ中,会发现使用很多传统的多条件查询很难实现。

这里提供网上已有的几种方法:

一、用表达式树依据IQueryable数据源构造一个动态查询

参见:博客园李永京http://ww...

# SharePoint 2010 &#8211; A developer point of view - Ricardo Garrido

Pingback from  SharePoint 2010 &#8211; A developer point of view - Ricardo Garrido