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 Articles
- How can I call a Linq-to-Entities (EF4) query specifying a different table name dynamically?
- Casting to a derived type in a LINQ to Entities query with Table Per Hierarchy inheritance
- LINQ to Entities three table join query
- How to join two table from two different edmx using linq query
- How can i copy data table records of different field name based on mapping list evaluating condition on source data table?
- Dynamically set the table name in LINQ query
- Linq to entities query with nested query on the same table
- Can I Use The Same Linq Code to Query for Different Conditions?
- Encapsulate LINQ query for different Repositories to avoid repeated code
- Convert SQL Server query to LINQ lambda query for two different cols from two different table that are related
- (Entity Framework) context.Database.SqlQuery return invalid object name for table but LINQ query works
- Run LINQ query with dynamic table name
- LINQ to Entities Table top 100 with using distinct name
- Trouble generating c# linq to entities (EF) query for a 3 table join with or and one table with no key relationships
- Forming linq query to get table data using table name
- linq query to select record having same name but different value in two columns
- How to LINQ Query Code First generated EF6 hierarchical entities (entities within entities)?
- Linq to Entities Join to Show Name in Lookup Table
- LINQ to entities Query group by and count from different tables
- Filter parent/child table (one to many association) in linq query based on entities in child table?
- how to get first object when the name is the same and Id is different with linq query
- Convert table name (in string) to use it in the LINQ query : C#, Entity Framework
- Entity Framework Code First - The entity or complex type cannot be constructed in a LINQ to Entities query
- Pass linq to entities query as parameter and execute against different objects
- Entity framework linq query Include() multiple children entities
- How do you construct a LINQ to Entities query to load child objects directly, instead of calling a Reference property or Load()
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- Linq To SQL: Sort Query by Arbitrary Property(Column) Name
- How do you return a default value if a LINQ to entities query returns no values
- Where to call .AsParallel() in a LINQ query
- sql to linq query convert
- Changing Combobox should update entity EF6
- Reorder LINQ result (take 1 row and move it to top) when a condition match
- compare two folders for non identical files with SymmetricDifference?
- Unexpected difference between IEnumerable and List as result of a linq-statement in .net-core?
- EF: Can I have single point for lambda to class instance conversion?
- c# only show numbers after decimal point with linq
- How to find an error in Linq using PropertyValidationErrors when key is not found in results
- How do I sort elements by the attributes of the elements' children?
- Filter not working appropriately- when inner joining tables
- Entity Framework - writing query using lambda expression
- How to create a MemberExpression for List<string>, for Expression<Func<T,bool>>
- How to search any items of a list within a string using Linq
- Nested Anonymous Type in LINQ
- c# linq returns duplicate data
- Efficient foreach child evaluation in parallel
- Accessing Linq Values in ViewData
- Working on DataGridView Combobox event and linq query not working
- How to find a holder of a property
- Writing to XML using XDocument, but knowing where to write