I have this Linq
var company = db.Companies.Where(x => x.id == Id).Select(x => new Company
{
Id = x.id,
Description = x.Description,
Website = x.Website,
Zip = x.Zip,
Actions = db.Actions.Where(a => a.UserCompanyId == Id).Select((a, index) => new CompanyActions
{
Id = index + 1,
Name = a.Name,
Duration = (int)a.Duration
}).ToList()
})
.FirstOrDefault();
I want to get Id of Actions - 1,2,3,4,5,6,7,8......
But in this case index doesn't work.
Error - + $exception {"LINQ to Entities does not recognize the method 'System.Linq.IQueryable
1 Select(System.Linq.IQueryable
1, System.Linq.Expressions.Expression1[System.Func
3])' method, and this method cannot be translated into a store expression."} System.NotSupportedException
All question is how can I increment (+1) Id in Actions? Want to see 1- Name 2 - Name 3-Name
this work fine
var company = db.Companies.Where(x => x.id == Id).AsEnumerable().Select(x => new Company
{
Id = x.id,
Description = x.Description,
Website = x.Website,
Zip = x.Zip,
Actions = db.Actions.Where(a => a.UserCompanyId == Id).AsEnumerable().Select((a, index) => new CompanyActions
{
Id = index + 1,
Name = a.Name,
Duration = (int)a.Duration
}).ToList()
})
.FirstOrDefault();