dynamic-linq

How to create a dynamic linq to entities query

Hello all. Now this is probably really easy but being the tool that I am, I'm not sure the best way to attack this problem. I have a DAL and a load of methods using EF that populate drop down lists in a UI. i.e. material, source. From these, I want the user to populate a gridview with the product data based upon their criteria they s...

Create new Linq SelectMany extension method

I am using Linq.Dynamic. I have already added another SelectMany extension to all for creating a new anonymous object with the data. But, I have ran into another issue that I can not seem to solve. I want to have extension method chaining as follows, but using the dynamic methods: var customerandorderflat = db.Customers .S...

LINQ: Dynamic .Where() Statements

Hi, Scenario: I have a list and three search filters. Something like: ResultList = OriginalList.Where(filter1).Where(filter2).Where(filter3); Question: Can I update filter 3, and then have the ResultList update, without having LINQ running filter1 and filter2? (I want to improve performance) Basically, it would be the same as: Re...

How to do Linq on ITypedList?

So far, I find Linq can be used on existing fields and properties of a class, not on virtual properties. In other words, ITypedList can not work with Linq, even by dynamic Linq. I tried the following code: IQueryable contact ; ... dynamic l = contact.Select("Customer.Name as Name"); // Customer is a virtual property provid...

Linq.Dyanmic GroupJoin Implementation

I am working on create an Extension Method in the Linq.Dynamic project for GroupJoin. But, for some reason it will not run. The signatures seem to match. public static IQueryable GroupJoin(this IQueryable outer, IEnumerable inner, string outerSelector, string innerSelector, string resultsSelector, params object[] values) { i...

Querying Entity with LINQ using Dyanmic Field Name

I have created a dynamic search screen in ASP.NET MVC. I retrieved the field names from the entity through reflection so that I could allow the user to choose which fields they wanted to search on instead of displaying all fields in the view. When the search result is Posted back to the controller, I receive a FormCollection containing...

How to refer to a field in a dynamic linq query?

I have a query that needs to be dynamic, I think most of my syntax is right but I do not know how to give it the name of the column I want to group by. I have tried a few different approaches and I always get an error - "No property or field 'name' exists in type 'datarow' IQueryable<Result> aggregate1 = query1Data.Tables[0].AsEn...

Syntax Error using dynamic linq with MVC 2.0's Ajax.BeginForm

Hey Guys, I got some problem with dynamic linq (link) and Ajax.BeginForm. Serverside I got the following Controller Action: [HttpPost] public ActionResult Ajax(String filter) { var count = (from e in context.Elements where(filter) select e).Count(); return Json(new { ElementCount = count }); } ...

DLinq morphed into which one -- Linq to SQL or the Entity Framework?

What happened to Dlinq? I heard a few years ago that it was abandoned. Was some of its code used to create Linq to SQL or the ADO.NET Entity Framework? Which one? In other words, which of the two latter technologies are a new avatar of the old DLinq? I am learning ADO.NET Entity Framework and since I am just starting out, I believe th...

dynamic table name linq-to-sql dynamic LINQ

Hello Everyone, i want to construct my query dynamically based on the contents user has selected. and i want to do this in LINQ-t0-SQL. i have seen this. but i don't want to use sql statements with datacontext. on googling a bit i have a feeling that this can be done using dynamic LINQ. can someone quote some example of similar scenario...

Linq: Dynamic Query Contruction: query moves to client-side

Hi all, I've been following with great interest the converstaion here: http://stackoverflow.com/questions/3769141/construct-query-with-linq-rather-than-sql-strings with regards to constructing expression trees where even the table name is dynamic. Toward that end, I've created a Extension method, addWhere, that looks like: static pub...

Entity Data Model, Dynamic Linq, multiple table dynamic Where clause, strongly typed return types

Hello, When writing a method for an oData service I have the below linq, for which I need to have a dynamic "where" clause to filter the results (the "new"s in the joins are for composite PKs in the Entity Data Model): var query = from pl in CurrentDataSource.ProductListing join pla in CurrentDataSource.ProductListingAttri...

Dynamic Linq: Get the current data context

I'm using the Dynamic Linq features described in: http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx which works fine as long as I'm only refering objects where foreign keys are setup properly. Is there any way to referense a Table where foreign keys aren't setup? i.e. so...

Dynamic LINQ GroupBy Multiple Columns

I need to translate the following LINQ query to Dynamic LINQ that accepts several grouping columns based on user input. Basically I have a bunch of dropdownlists that apply groupings and I don't want to enumerate every combination of groupings. If Dynamic LINQ fails, I may have to construct a SQL query manually, and nobody wants that. ...