dynamic-linq

Make a dynamic query with Linq using a drop down list selected option in Asp.net MVC

Hi everyone! I'm trying to accomplish this with Linq to Sql and Asp.Net MVC: I have a Drop Down List with options Country, City and State. And beside it, there is a textbox. So, an user will, for instance, select City and will type "new york city" in the textbox and the application will show himm the results of his choice. So, how ca...

System.LINQ.Dynamic: Select(" new (...)") into a List<T> (or any other enumerable collection of <T>)

Hi All, Say I have a DataTable with four columns, Company (string), Fund (string), State (string), Value(double): table1.Rows.Add("Company 1","Fund 1","NY",100)); table1.Rows.Add("Company 2","Fund 1","CA",200)); table1.Rows.Add("Company 3","Fund 1","FL",300)); table1.Rows.Add("Company 4","Fund 2","CA",400)); table1....

Dynamic Linq Sort Nested Table

Follow up question to this: http://stackoverflow.com/questions/1488414/linq-combine-left-join-data Say I have the following db tables: Users ------- UserId (PK) UserName Roles ----- RoleId (PK) RoleName UserRoles --------- UserId (PK) RoleId (PK) Users 1-M UserRoles M-1 Roles Using LinqToSQL, I can return the following set (thanks...

Dynamic LINQ API - SQL Convert Function

I'm trying to use a Dynamic LINQ Query to query a SQL database, and in the Where clause I need to evaluate an '=' condition with a field that is of type TEXT. Right now, I've got this: var result = DBCon.PcInValue .Where(String.Format("InputName = @0 and InputValue) {0} @1", f.Condition), f.Field, f.Value) .Select("new(OrderNum, ...

Dynamic LINQ with other databases

Are there any free (gratis) providers for databases other MS SQL (e.g. MySQL or SQLite) that work with LINQ and support dynamic SQL query generation? E.g. table.Count() generates something like SELECT COUNT(*) FROM table and doesn't first load the whole table and then count the rows. ...

dynamically create lambdas expressions + linq + OrderByDescending

how can I create a dynamic lambda expression to pass to use in my orderby function inside linq? I basically want transform "queryResults.OrderByDescending();" in "queryResults.OrderByDescending(myCustomGeneratedLambdaExp);" where myCustomGeneratedLambdaExp shall be a string containning "x => x.name" Thanks ...

Handle a Dynamic Select With Dyanmic Linq

I am using the Dynamic Linq Library that Scott Guthrie describes here. Scott Guthrie's examples are great and I have used the dynamic Where statements quite a bit. Now, however, I am faced with a situation where I need to use the dynamic select functionality. Scott Guthrie shows a screenshot of this functionality (in the very last...

Is it possible to build dynamic LINQ queries to non-strongly type datatables?

Using LINQ, I've been trying to use the System.Linq.Dynamic library in order to query a datatable dynamically. The problem is that it's not strongly typed, and the extension method for select is expecting an IEnumerable as the source. Is there a way to work around this? Example code: var query = dataSet.Tables[0].AsEnumerable().Select...

How to do the following in Dynamic Linq using System.Linq.Dynamic namespace

Hi, I just want to know how to do the following in Dynamic Linq using System.Linq.Dynamic namespace var query2 = db.Customers.Select( cust => new Customer { FirstName = cust.FirstName, LastName = cust.LastName Tags="sampleTag...

Dynamic where clause in Linq

I know there are a lot of examples of this on the web, but I can't seem to get this to work. Let me try to set this up, I have a list of custom objects that I need to have limited on a range of values. I have a sort variable that changes based on some action on the UI, and I need to process the object differently based on that. Here...

system.linq.dynamic: building a dynamic projection

I apologize in advance for not being able to give a code sample. It would be problematic and not quite clear but the pseudo below may suffice. What I'm attempting to do is construct a dynamic projection leveraging system.linq.dynamic. I'm, at times, asking LinqToSql to do some magic and asking for properties in a related entity by usi...

Dynamic JOIN across WCF Data Services

I am prototyping a generic data browser over WCF Data Services. The user can select the entities from a TreeView, thus I cannot hardcode the query result types and have to code the queries (URI or LINQ) dynamically. To offer joins across different Data Services I am loading the results from each Data Service to the client an try to dyn...

Dynamic query to immediate execute?

I am using the MSDN Dynamic linq to sql package. It allows using strings for queries. But, the returned type is an IQueryable and not an IQueryable<T>. I do not have the ToList() method. How can I this immediate execute without manually enumerating over the IQueryable? My goal is to databind to the Selecting event on a linqtosql datas...

Dynamic Linq Library Help

I have the following class: public class Item { public Dictionary<string, string> Data { get; set; } } and a list of it: List<Item> items; I need to filter and order this list dynamically using SQL-Like strings. The catch is, that I need to order it by the Data dictionary. For example: Order By Data["l...

Dynamic Linq help, different errors depending on object passed as parameter?

I have an entityDao that is inherbited by everyone of my objectDaos. I am using Dynamic Linq and trying to get some generic queries to work. I have the following code in my generic method in my EntityDao : public abstract class EntityDao<ImplementationType> where ImplementationType : Entity { public ImplementationType getOneByValu...

How dynamic can I make my LINQ To SQL Statements?

I have the need to construct a LINQ To SQL statement at runtime based on input from a user and I can't seem to figure out how to dynamically build the WHERE clause. I have no problem with the following: string Filters = "<value>FOO</value>"; Where("FormattedMessage.Contains(@0)",Filters) But what I really need is to make the entire W...

Dynamic Linq : is it stable ?

Dynamic Linq is provided as a sample for VS2008, not as a "real" project (no official site, no support, no issue tracking, no new releases...). So I was wondering, how reliable is it ? Is it suitable for production use ? ...

dynamic query using expression tree

I have a form in which the user will choose the following from dropdown lists: table_name columnName_to_sort_by columnName_to_search_in The user shall enter Search_text in a text box The form shall draw data from many tables. I want to avoid writing the sort and search for every field for each of the tables. This is w...

How can I use dynamic LINQ in my asp.net project?

How can I use dynamic LINQ in Visual Studio 2008? I'm trying to use using System.linq.Dynamic but there is no intellisense. How can I use it? ...

Query File System Info Dynamically using LINQ

Hi I need to be able to return a list of files that meet some dynamic criteria. I've tried to do this using LINQ. I've found that it is possible to use dynamic LINQ using the System.Linq.Dynamic namespace that it is mentioned in Scott Gu's Blog. But I'm not sure if can be used for what I need it for. So far I get all the files but ...