score:2
Accepted answer
private bool validatelinkedfield(string fieldname)
{
//loop through the "levels" (e.g. order / customer / name) validating that the fields/properties all exist
type currenttype = resulttype;
foreach (string currentlevel in dequalifyfieldname(fieldname, resulttype))
{
memberinfo match = (memberinfo)currenttype.getfield(currentlevel) ?? currenttype.getproperty(currentlevel);
if (match == null) return false;
currenttype = match.membertype == membertypes.property ? ((propertyinfo)match).propertytype
: ((fieldinfo)match).fieldtype;
}
return true; //if we checked all levels and found matches, exit
}
Source: stackoverflow.com
Related Query
- Generate Multi-Parameter LINQ Search Queries with Run-time Specified Return Type
- How To run LINQ queries with Generic type
- How To run LINQ queries with Type of <T>
- Does Linq search the entire database when I run a select statement with a time restricting where clauses?
- Error: "The specified LINQ expression contains references to queries that are associated with different contexts"
- Return input type of generic with type constraint in LINQ to Entities (EF4.1)
- How to write LINQ query with column name as parameter still in a type safe way
- Create Generic Type with Generic Interface at Run Time
- When selecting an anonymous type with LINQ from EF, is there no way to run a method on an object as you select it?
- Inconsistent return types of linq queries with orderby clauses
- Is possible to run a query with linq to search for a period of time?
- LINQ query to get all entities with member of specified type
- How to generate a LINQ query that queries all non-null properties from a search page model
- C# Linq select/join with custom return type
- The specified LINQ expression contains references to queries that are associated with different contexts error in c#
- What is meant by 'The specified LINQ expression contains references to queries that are associated with different contexts'
- LINQ search list of type Node with WHERE
- How to return DateTimeOffset type with Linq
- Linq Lambda Error : The specified LINQ expression contains references to queries that are associated with different contexts
- The specified type member '' is not supported in LINQ to Entities: I'm ordering by a property of the class I want to return
- Union two models together causes "The specified LINQ expression contains references to queries that are associated with different contexts."
- returning specified type for a linq query with anonymous type
- Only capture element with Linq to XML if parent is of specified type
- Is it possible to combine 2 view models, each populated with 2 different LINQ queries and return to 1 view?
- Linq query to execute stored procedure with return type as DataTable
- How to run Linq on DataTable with SQL like 'IN' and return DataTable C#?
- Run time exception "Conversion from string to type 'Boolean' is not valid." in LINQ
- Linq to Entities Object with IQueryable property run all queries simultaneously
- Error: the specified linq expression contains references to queries that are associated with different context
- The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties
More Query from same tag
- Return only certain columns to JSON in LINQ
- LINQ equivalent of my SQL Query for UNION ALL
- reading JSON data and loop through the data to get the certain value based on conditions
- Linq-asp.net Core- Get the only one row after grouping
- Reverse a string and get an error
- XML to dropdown list using LINQ
- Table Valued Function and Entity Framework
- fetch data in dropdownlsit using linq
- How to speed up LINQ inserts with SQL CE?
- Working with DataGridViewRow.DataBoundItem - transform to Enumerable Object?
- How to take array segments out of a byte array after every X step?
- In Linq2SQL, how do I get a record plus the previous and next in the sequence in a single query?
- LINQ Query error: Unable to create a constant value of type. Only primitive types or enumeration types are supported in this context
- how to get all columns name from multiple table in a dataset by LINQ
- new blank, non null anonymous type
- How to add listviewitems to an array when the check can be one or more items in a string array?
- Outer Joins and Linq
- Create groupings using GroupBY
- LIKE in "where" LINQ statement causes error
- remove duplicate values from a list with multiple properties
- c# getting last element in LINQ statement
- NullReferenceException when retrieving values from LINQ to DataTable
- LINQ How to select more than 1 property in a lambda expression?
- Linq equivalent of for in foreach
- Linq OrderBy doesn't return expected results
- C# Left join linq results in ORA-12704 when selecting a default string value
- LINQ join is not using Equals from provided EqualityComparer, uses GetHashCode instead
- LINQ: Query a collection within a collection
- How do write LINQ query to do recursion?
- how to efficiently Comparing two lists with 500k objects and strings