Anyone know how to do this very basic subquery in LINQ?
(just trying to get the number of active contracts per vendor)
SELECT a.VendorID,a.Name, (SELECT count(Agency_Code) from Contracts b where b.Vendor_Code = a.VendorID) FROM Vendors a
yields:
10001 Becker Inc 4
10002 Carlisle Inc 0
etc
Riddhi ValechaPosted Sep 15, 2021, 4:17 PM
List<int> IdsToFind = new List<int>() {2, 3, 4}; db.Users .Where(u => SqlMethods.Like(u.LastName, "%fra%")) .Where(u => db.CompanyRolesToUsers .Where(crtu => IdsToFind.Contains(crtu.CompanyRoleId)) .Select(crtu => crtu.UserId) .Contains(u.Id) )