score:3
You can create a function that takes an IQueryable as a parameter.
The function would look like:
private void CheckTable(IQueryable<EntityType> table)
{
var stage = (from s in table select s.ResourceId).ToList();
foreach (var invalidResourceID in stage.Except(res).ToList())
{
errList.Add("Bad ID found:" + invalidResourceID);
}
}
// Execute the function like:
CheckTable(dc.TableOne);
You can choose if you make errList and res class level properties or if you pas them as parameters to the function
score:0
With some modification I was able to get this to work - I had to use the built in dynamic linq to select the property that I wanted.
private void CheckTable(System.Data.Objects.ObjectSet<EntityType> table)
{
var records = table.Select("BusinessEntityNbr").ToList();
var values = (from r in records select (int?)r[0]).ToList();
foreach (var invalidResourceID in values.Except(res).ToList())
{
errList.Add("Bad ID found:" + invalidResourceID);
}
}
score:0
You may want to consider using entity SQL and DbDataRecord for unknown result types. See the Entity SQL samples in http://archive.msdn.microsoft.com/EFQuerySamples for some ideas on how to use Entity SQL.
Source: stackoverflow.com
Related Query
- How can I call a Linq-to-Entities (EF4) query specifying a different table name dynamically?
- How can i copy data table records of different field name based on mapping list evaluating condition on source data table?
- How can I call local method in Linq to Entities query?
- How can I write the following code more elegantly using LINQ query syntax?
- How can I code a Linq query to do an upward Include?
- How to join two table from two different edmx using linq query
- How can I implement Query Interception in a LINQ to Entities query? (c#)
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- How can I set custom property of an Entity type in LINQ to Entities query and still return a IQueryable<T>?
- How can I code numerous MIN functions into one LINQ to DataSet query
- How can I do a LINQ query joining two entities and select what a Where on one of the entities?
- How can I convert Linq to Entities Query into expression tree?
- Can I Use The Same Linq Code to Query for Different Conditions?
- LINQ to Entities is pluralizing table names actually executed in SQL Server. How can I avoid it?
- How can I use custom expressions in DevArt LINQ to Entities and also use query comprehension syntax?
- How can I use this extension method in a linq to entities query using query syntax?
- How to LINQ Query Code First generated EF6 hierarchical entities (entities within entities)?
- How can I make a JOIN query with LINQ between two tables (entities) with many-to-many relationship, while there is no joining table in EF?
- How do I write a linq to sql query to find records where field name can match one of dynamic number of strings?
- How can I speed up my LINQ query without using a table twice?
- how to get first object when the name is the same and Id is different with linq query
- How can I query my join table (many-to-many) using Linq and EF6 (get a users roles)
- how can i call the delete store procedure in linq query
- How can we get list of two column say firstname and lastname from customer table in mvc using linq query
- How can I write a LINQ query towards a table in the Local Storage Account?
- How can I call function inside Linq to Entities query?
- How can I build a linq query at runtime with multiple group by clauses with different types
- How do you construct a LINQ to Entities query to load child objects directly, instead of calling a Reference property or Load()
- Casting to a derived type in a LINQ to Entities query with Table Per Hierarchy inheritance
- How can I set properties on all items from a linq query with values from another object that is also pulled from a query?
More Query from same tag
- C# change date format from dd/MM/yy to dd/MM/yyyy in datatable
- How to query with Linq a List that contains a list of lists that contains a list of lists that contains a list of objects?
- C# MongoDB Driver: Querying Array of Authors for partial or complete match on author full name
- WPF, Linq to SQL, C# > How to Populate and Save A Combobox
- getting most inner type object in one to many relation in linq
- LInq querying collection inside collection
- LINQ query continues to return null after 1st successful call
- C# LINQ how to flatten parent list and two nested children lists into a new list
- Automapper Custom Map use "Include" to get children count
- SQL query to LINQ expression - Entity Core Framework 3 + SQL Server
- Changing DBML, how to change SQL database?
- How to get compile-time checking for value types in LINQ/lambdas/expression trees?
- Intersect N SortedLists<T> in c#
- Trying to close DataReader
- IN query using LINQ for IEnumerable List of items
- Excluding specific records using LINQ query
- convert C# Linq to T-Sql
- Permissions error in C# application, System.Net.NetworkInformation?
- Can you reuse a LINQ datacontext in an ASP.NET MVC application with strongly typed views
- Lambda function in LINQ select clause
- How to merge a collection of collections in Linq
- Output duplicate rows in a list
- Another issue about LINQ
- asp.net mvc Linq going through 1 million records(proccess time)
- Convert list of of objects to list of tuple without iterating
- Error serializing linq result
- Get all the text under a element
- Using Except() on a Generic collection
- How to dynamic use SqlFunctions.PatIndex
- lambda and linq expression