------最佳解决方案-------------------- 那就用2、3楼版主说的试试,不过我记得获取实体类型时不能用这种投影方法,会出现错误,你试一下,没有问题最好。 ------其他解决方案-------------------- select CompanyInfo 就行了,干吗要再转换成匿名对象?你用select new { AutoID=CompanyInfo.AutoID, CompanyAddress=CompanyInfo.CompanyAddress, CompanyName=CompanyInfo.CompanyName, CompanyTel=CompanyInfo.CompanyTel }这个出来的就不是Company_Info对象了,当然会有类型错误的问题 ------其他解决方案-------------------- select new { ...
=>
select new CompanyInfo() { ... ------其他解决方案--------------------
++
var Query1 = from CompanyInfo in ef.Company_Info orderby CompanyInfo.Company_ID descending select new Company_Info{ AutoID=CompanyInfo.AutoID, CompanyAddress=CompanyInfo.CompanyAddress, CompanyName=CompanyInfo.CompanyName, CompanyTel=CompanyInfo.CompanyTel }; ------其他解决方案--------------------