score:0
As mentioned, Linq does not play well with dynamic
. Linq makes heavy use of extension methods, which much be bound at compile-time and thus you can't use dynamic
since it defers all binding to run-time.
If you have two datasets that do not have a common base type or interface, but have the same entity types (by name at least), then you'll need two overloads. You might be able to refactor part of it to improve reuse:
private void CallCustomerCodeDynamically(CustmoerEntities1 customerEntities)
{
var customerCode= from customer in customerEntities.CustomerInfoes
orderby customer.CustomerCode ascending
select customer.CustomerCode;
BindCodes(customerCode);
}
private void CallCustomerCodeDynamically(CustmoerEntities2 customerEntities)
{
var customerCode= from customer in customerEntities.CustomerInfoes
orderby customer.CustomerCode ascending
select customer.CustomerCode;
BindCodes(customerCode);
}
private void BindCodes(IEnumerable<string> customerCode)
{
ddlCustomerCode.DataSource = customerCode;
ddlCustomerCode.DataBind();
}
Source: stackoverflow.com
Related Query
- Query expressions over source type 'dynamic' or with a join sequence of type 'dynamic' are not allowed
- LINQ TO SQL, Dynamic query with DATE type fields
- LINQ Query Field<T> with dynamic type
- How can I do an OrderBy with a dynamic string parameter order on a join query
- Linq Query with dynamic type
- Join dynamic query result with an EntitySet using Linq?
- How to do Entity Framework/Linq join in query with where clause expressions
- Dynamic linq query with join
- error :Could not find an implementation of query for source type datatable and join not found while trying to join two datatables
- Dynamic Linq query for join two tables with more than one condition(dynamically)
- The type of one of the expressions in the join clause is incorrect in Entity Framework
- Dynamic query with OR conditions in Entity Framework
- Could not find an implementation of the query pattern for source type 'System.Data.Entity.DbSet'
- Casting to a derived type in a LINQ to Entities query with Table Per Hierarchy inheritance
- How do I do a left outer join with Dynamic Linq?
- How do I most elegantly express left join with aggregate SQL as LINQ query
- LINQ select query with Anonymous type and user Defined type
- LINQ - 'The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'GroupJoin'.'
- Equivalence of query and method (lambda) syntax of a Join with Where clause
- The type of one of the expressions in the join clause is incorrect when the types are the same
- How can I build Linq query with dynamic OR statements?
- When to prefer joins expressed with SelectMany() over joins expressed with the join keyword in Linq
- join list with linq-to-sql query
- LINQ query with GROUP BY and Count(*) into Anonymous Type
- Dynamic linq query with multiple/unknown criteria
- nhibernate queryover with complex join over non-related entities
- Dynamic Where Clause over relational tables with LINQ to SQL
- linq query with dynamic predicates in where clause joined by OR
- Using LINQ Dynamic Query Library with Dictionary<string, object> and .AsQueryable()
- How can I create a dynamic LINQ query in C# with possible multiple group by clauses?
More Query from same tag
- How to find duplicate in a list and update the same list
- Add to collection if not already available with linq
- How to group by a new string in LINQ
- LINQ: Using INNER JOIN, Group and SUM
- C# Cast list using Linq using Where function
- Why does comparing integers with Equal(=) takes 800ms more that using GreaterThan(>) and LessThan(<)
- DataTable Data List with Related Column on Asp.Net
- SQL to LINQ - multiple tables left outer join with where clause referring right table
- Acces to parent's attribute from descendant
- Update data in another list change all my data
- LINQ to XML: suppressing redundant namespace attribute in child nodes
- Regex take numbers from string c#
- I want take the last 4 record but always get the first 4
- Sql Select Statement Issue in order by
- Using Linq To Convert ListBox Items Values to int
- C# Full text search with Linq
- LINQ Query to find all tags?
- Trying to find some Tags via a collection of where clauses in .NET Linq
- LINQ - Where clause with Boolean method
- Convert single LINQ value to string
- is it possible to Query an Odata service and expand Child of Child entities?
- Linq Contains to return ALL items or selected ones?
- How to use LINQ to separate column entry and count
- Dynamic variable to call appropriate class property inside LINQ
- Change all values of a list with new with linq
- Passing Func to method where the func needs parameters from inside method
- Foreach item changes not preserved outside loop
- handling null values of datetime
- Update entity in mvc4
- 3 arrays to 1 IEnumerable<test>