UserAuthorizations table has Company per User wise, and I want to get the list of Companies for the Users which are assigned as to them.
// GET: odata/Companies/GetUserCompanies
[EnableQuery]
public IQueryable<UserAuthorization> GetUserCompanies()
{
List<int> userCompanyIds = db.UserAuthorizations.Where(u => u.Cwid == this.UserId).Select(s => s.CompanyId).ToList();
return db.Companies.Where(m => m.Id.ToString().Contains(userCompanyIds));
}
For above I am getting error like
Cannot convert from 'System.Collections.Generic.List<int>' to 'string'
try it
public IQueryable<Company> GetUserCompanies()
{
List<int> userCompanyIds = db.UserAuthorizations.Where(u => u.Cwid == this.UserId).Select(s => s.CompanyId).ToList();
return db.Companies.Where(m => userCompanyIds.Contains(m.Id));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.