连接的MVC 4控制器操作结果给出错误 [英] MVC 4 controller action result for join gives error

查看:67
本文介绍了连接的MVC 4控制器操作结果给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调用索引页面并从两个表中获取数据我使用Entity framework DB第一种方法并生成模型类现在我想修改我的模型类,见下文。



I am calling index page and get data from two table i used Entity framework DB first approach and generate model classes now i want to amend my model class see below.

private kcdrEntities db = new kcdrEntities();
public ActionResult Index()
       {
           var query = from pp in db.kcdr_tprovinces
                             join cc in db.kcdr_tcountries on new
                             {
                                 pp.CountryID,
                                 pp.ProvinceName
                             } equals new { cc.CountryID , cc.CountryName }
                             select new { pp.ProvinceName, cc.CountryName };

          return View(query.ToList());
       }





IT在加入声明中给出错误..

错误1 join子句中某个表达式的类型不正确。调用加入时类型推断失败。

请指导我谢谢



IT gives error on join statement..
Error 1 The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'.
Please guide me thankx

推荐答案

尝试在连接中定义和使用具体类而不是匿名的。
Try defining and using a concrete class in the join instead of anonymous one.


这篇关于连接的MVC 4控制器操作结果给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆