【发布时间】:2014-05-13 09:51:47
【问题描述】:
我在加入两个表时遇到了麻烦,并继续收到“无法从用法中推断出来。尝试明确指定类型参数。”。
"错误 2 方法的类型参数 'System.Linq.Enumerable.Join(System.Collections.Generic.IEnumerable, System.Collections.Generic.IEnumerable, 系统函数,系统函数, System.Func)' 不能从 用法。尝试明确指定类型参数。 C:\Pro Asp.net Mvc 5\Chapter 13\1\SportsStore - 复制\SportsStore.WebUI\Controllers\DocProductController.cs 29 17 SportsStore.WebUI"
谁能帮帮我?
public class DocProductController : Controller
{
private IDocProductRepository repository;
private IDocMainRepository repositoryMain;
public DocProductController(IDocProductRepository docProductRepository, IDocMainRepository docMainRepository)
{
this.repository = docProductRepository;
this.repositoryMain = docMainRepository;
}
public ViewResult List()
{
DocProductListView model = new DocProductListView
{
DocProduct = repository.DocProduct
.Join(repositoryMain.DocMain,
docProduct => docProduct,
docMain => docMain.Doc_Id,
(docProduct, docMain) => new { a = docMain.Doc_Id, b = docProduct.Doc_Id })
//.OrderByDescending(n => n.DocMain)
};
return View(model);
}
}
public partial class DocMain
{
public int Doc_Id { get; set; }
public Nullable<int> Category_Id { get; set; }
public string Doc_Title { get; set; }
public Nullable<int> Doc_Order { get; set; }
public Nullable<byte> Doc_IsAudit { get; set; }
public Nullable<int> Doc_Clicks { get; set; }
public string Doc_TitleColor { get; set; }
public string Doc_Author { get; set; }
public Nullable<int> User_Id { get; set; }
public string Doc_Source { get; set; }
public string Doc_Thumb { get; set; }
public Nullable<System.DateTime> Doc_DisplayTime { get; set; }
public Nullable<System.DateTime> Doc_ReleaseTime { get; set; }
public Nullable<System.DateTime> Doc_UpdateTime { get; set; }
public string Doc_SEO_Title { get; set; }
public string Doc_SEO_Description { get; set; }
public string Doc_SEO_Keywords { get; set; }
public string Doc_RedirectUrl { get; set; }
public Nullable<byte> Doc_GenerateHTML { get; set; }
public string Doc_HTMLCatagory { get; set; }
}
public partial class DocProduct
{
public int Doc_Id { get; set; }
public Nullable<int> Category_Id { get; set; }
public string DocProduct_Content { get; set; }
}
【问题讨论】: