LINQ to Entities 不识别方法"System.String ToString()"该怎么解决
LINQ to Entities 不识别方法"System.String ToString()"
这里的 CreateTime = c.CreateTime.ToString(),
UpdateTime = c.UpdateTime.ToString(),会在执行时报错LINQ to Entities 不识别方法"System.String ToString()"。请问该怎么写?
------解决思路----------------------
var query = (from a in context.Users
from b in context.Companies
from c in context.Accounts
where a.Id == c.CreateUser && c.CompanyId == b.Id && c.AllPassState == false
select new WaitAuditEntity
{
a,b,c
}).ToList().select(x=>new{
//这里写一次
});
------解决思路----------------------
var query = from a in context.Users
from b in context.Companies
from c in context.Accounts
let _CreateTime c.CreateTime.ToString(), _UpdateTime = c.UpdateTime.ToString()
where a.Id == c.CreateUser && c.CompanyId == b.Id && c.AllPassState == false
select new WaitAuditEntity
{
Id = c.Id,
AccountName = c.AccountName,
ContactName = c.ContactName,
CompanyName = b.CompanyName,
OpenCompany = a.BelongsCompany,
Mobile = c.Mobile,
AccountState = c.AccountState,
PaymentState = c.PaymentState,
ReviewState = c.ReviewState,
EstablishState = c.EstablishState,
AllPassState = c.AllPassState,
CreateTime = _CreateTime ,
UpdateTime = _UpdateTime ,
CreateUserName = a.Name
};
var query = from a in context.Users
from b in context.Companies
from c in context.Accounts
where a.Id == c.CreateUser && c.CompanyId == b.Id && c.AllPassState == false
select new WaitAuditEntity
{
Id = c.Id,
AccountName = c.AccountName,
ContactName = c.ContactName,
CompanyName = b.CompanyName,
OpenCompany = a.BelongsCompany,
Mobile = c.Mobile,
AccountState = c.AccountState,
PaymentState = c.PaymentState,
ReviewState = c.ReviewState,
EstablishState = c.EstablishState,
AllPassState = c.AllPassState,
CreateTime = c.CreateTime.ToString(),
UpdateTime = c.UpdateTime.ToString(),
CreateUserName = a.Name
};
这里的 CreateTime = c.CreateTime.ToString(),
UpdateTime = c.UpdateTime.ToString(),会在执行时报错LINQ to Entities 不识别方法"System.String ToString()"。请问该怎么写?
------解决思路----------------------
var query = (from a in context.Users
from b in context.Companies
from c in context.Accounts
where a.Id == c.CreateUser && c.CompanyId == b.Id && c.AllPassState == false
select new WaitAuditEntity
{
a,b,c
}).ToList().select(x=>new{
//这里写一次
});
------解决思路----------------------
var query = from a in context.Users
from b in context.Companies
from c in context.Accounts
let _CreateTime c.CreateTime.ToString(), _UpdateTime = c.UpdateTime.ToString()
where a.Id == c.CreateUser && c.CompanyId == b.Id && c.AllPassState == false
select new WaitAuditEntity
{
Id = c.Id,
AccountName = c.AccountName,
ContactName = c.ContactName,
CompanyName = b.CompanyName,
OpenCompany = a.BelongsCompany,
Mobile = c.Mobile,
AccountState = c.AccountState,
PaymentState = c.PaymentState,
ReviewState = c.ReviewState,
EstablishState = c.EstablishState,
AllPassState = c.AllPassState,
CreateTime = _CreateTime ,
UpdateTime = _UpdateTime ,
CreateUserName = a.Name
};