Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional ADO.NET 3.5 with LINQ and the Entity Framework ISBN: 978-0-470-22988-0
This is the forum to discuss the Wrox book Professional ADO.NET 3.5 with LINQ and the Entity Framework by Roger Jennings; ISBN: 9780470182611
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ADO.NET 3.5 with LINQ and the Entity Framework ISBN: 978-0-470-22988-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 8th, 2009, 03:39 AM
Registered User
 
Join Date: Jun 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Question Creating Dynamic Where Clause In LINQ

I have a problem to create dynamic Where clause in LINQ Query.

I am try to use the following code in which i am filtering the multiple record of the same columns.
Code:
 List<string> FilterList = new List<string>();
 FilterList.Add("ABC"); 
 FilterList.Add("ABD");
 FilterList.Add("ABE");
 var REFD = from dcodes in Program.LookupData.G_CODES.AsEnumerable()
                       where FilterList.Contains(dcodes.CODE_VALUE)
                           select new
                           {
                               CODE = dcodes.Field<string>("CODE_VALUE"),
                               DESC = dcodes.Field<string>("DESCR")
                           };
The above code filter a record just as like operator.
I am also trying to other way given below.
Code:
var REFD = from dcodes in Program.LookupData.G_CODES
                       .where("CODE_VALUE = 44 AND DESC = 'ddd' ")
                       .Orderby("CODE_VALUE")
                           select new
                           {
                               CODE = dcodes.Field<string>("CODE_VALUE"),
                               DESC = dcodes.Field<string>("DESCR")
                           };
IF there is any other best way to dynamically build the Query Please let me know about. thanks for early message.


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating dynamic textboxes djricochet ASP.NET 2.0 Professional 0 March 14th, 2006 12:04 PM
Stored Procedure - Dynamic Where Clause Terry_Pino BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 July 2nd, 2004 04:39 PM
Creating Dynamic Images mvollmer Classic ASP Basics 0 March 4th, 2004 01:31 PM
creating dynamic list fyeojo VS.NET 2002/2003 4 September 2nd, 2003 03:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.