score:3
Accepted answer
You don't need LINQ for this.
Instead, you can check masterRow.GetChildRows("RelationName").Length
.
EDIT: You should use a DataRelation.
If you really don't want to, you can check
childTable.AsEnumerable().Any(dr => dr["ParentIdColumn"] == someValue)
EDIT: To check for multiple parents:
var parentKeys = parentRows.Select(dr => dr["id"]).ToList();
if (childTable.AsEnumerable().Any(dr => parentKeys.Contains(["ParentIdColumn"])))
Source: stackoverflow.com
Related Articles
- Determine if foreign key table has any links to primary key table with LINQ & DataTable
- Need help with LINQ to SQL WHERE-clause on foreign table
- Determine table during runtime with Linq
- Get foreign key table with a single query using LINQ
- Updating table with composite primary key using LINQ
- Add row to Entity Framework with hidden foreign key table and Linq
- linq to sql c#: replace a foreign key with its string value and keep the table structure
- Generic code to determine how many rows from a table are in a different table with matching structure?
- Linq and EF: Querying to get results on one to many relationships: Selecting table with foreign Key
- Linq joining same table with 4 different foreign keys
- Get all Column of foreign key table along with main table column in LINQ
- Casting to a derived type in a LINQ to Entities query with Table Per Hierarchy inheritance
- How to insert a record with LINQ and C# and return the Primary Key of that record
- Linq to Entity Join table with multiple OR conditions
- Entity Framework retrieve data from table with foreign key
- Deleting rows in a table with Linq to SQL
- LINQ to SQL entity column name attribute ignored with guid primary key
- How to get the latest date inserted from the table with Linq to entities
- LINQ table join with entity Framework
- Linq insert with no primary key
- Linq to Entities, Table per Type and Nullable Foreign Key Relationships
- Joining two tables with LINQ while also returning null records from the second table
- Linq to SQL insert with primary key as tinyint set to auto-increment gives error message
- LINQ Source Code Available
- Read huge table with LINQ to SQL: Running out of memory vs slow paging
- Create table with Linq to Sqlite (linq2db)
- linq join table with collection
- Linq with where clause in many-to-many EF Code First object
- Linq to 3 tables with no foreign keys
- how to create a pivot table with dynamic column using linq tree expression
- Linq stored procedure with dynamic results
- Query is not showing proper result
- how to get these stuff into linq in C#?
- How to find(query) through a complex array for checking in IMongoCollection and LINQ?
- Count Distinct - Inner Join - Group By / With the new Linq-to-NHibernate Provider
- Linq dynamic where clause query to find rows which contains 1st charater is numeric
- Sitecore data API, LINQ and language versions
- Linq query where clause in sub list
- LINQ to SQL Pivot table in VB.net
- linq list string like
- EntityFramework count members with condition C#
- LINQ cast int64 issue
- How to order a LinQ result set created by a list of ID and order it use existing order of the list
- Get unique values from a dataset using linq
- Obtain the index of the maximum element
- GetAll or GetList Functions And Performance Problem
- How to convert SQL subquery to Linq
- Linq Sub Query is not working
- Convert LINQ query expression
- Alternative to using a ternary operator in Lambda