如何通过linq获取项目等于新项目列表的数据 [英] how to get data where item equal a new list of items by linq

查看:74
本文介绍了如何通过linq获取项目等于新项目列表的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨ii这是CP Plz给我的第一个帮助请求如果你可以帮助我不要停止



i必须知道如何获得清单从数据库中它必须等于其中一个项目



```MyCode



\` ``MVC

Hi ii All this is the first help request to me in CP Plz if you can help me Don't stop

i have to know how can i get list from database it have it must equal one of anther items

```MyCode

\```MVC

public IEnumerable<SEC_MENUS> _MenuPV()
      {
          /* get The List Of Rule  */
          var _UserCODE = 604;//HttpContext.Session["USER_CODE"].ToString();
          var _RuleList = db.SEC_USER_RULE.ToList().Where(a => a.USER_CODE ==  _UserCODE).Select(i=>i.RULE_CODE);
          /*End*/

          
          /* Get List Of Fun Table By list of Rule code  */

          var FutbList = db.FUNCTION_TABLE.ToList().Where(se => se.RULE_CODE == __RuleList); // <<-- the problem here is (Operator '==' cannot be applied to operands of type 'short' and 'System.Collections.Generic.IEnumerable<short>)
          /*End*/

          /* Get List Of Menus By List Of FunTble  */
          var titlesInIdList = db.SEC_MENUS.ToList().Where(d => d.ITEM_CODE ==  FutbList);<<-- the problem here is (Operator '==' cannot be applied to operands of type 'int' and 'System.Collections.Generic.IEnumerable<int>)
             //var x = db.SEC_MENUS.ToList().OrderBy(a => a.MENU_CODE);
/*End*/
          return titlesInIdList;

      }





\```

```



\```
```

推荐答案

您好,



在此更正为:



/ *获取趣味表列表按规则代码列表* /



var FutbList = db.FUNCTION_TABLE.ToList()。其中​​(se = > __RuleList.contains(se.RULE_CODE));

//<< - 这里的问题是(运算符'=='不能应用于'short'类型的操作数和'System.Collections.Generic.IEnumerable< short>)

/ *结束* /



就像这样你也可以改变其他查询
Hi,

Make it correction here is :

/* Get List Of Fun Table By list of Rule code */

var FutbList = db.FUNCTION_TABLE.ToList().Where(se => __RuleList.contains(se.RULE_CODE));
// <<-- the problem here is (Operator '==' cannot be applied to operands of type 'short' and 'System.Collections.Generic.IEnumerable<short>)
/*End*/

Like that way you can change in other query as well


public IEnumerable<SEC_MENUS> _MenuPV()
      {
          /* get The List Of Rule  */
          var _UserCODE = 5000;//HttpContext.Session["USER_CODE"].ToString();
          var _RuleList = db.SEC_USER_RULE.ToList().Where(a => a.USER_CODE == _UserCODE).Select(i=>i.RULE_CODE);
          /*End*/

          
          /* Get List Of Fun Table By list of Rule code  */
          var FutbList = db.FUNCTION_TABLE.Where(o => _RuleList.Contains(o.RULE_CODE) ).Select(h=>h.ITEM_CODE).ToList();

          /*End*/

          /* Get List Of Menus By List Of FunTble  */

          var titlesInIdList = db.SEC_MENUS.Where(d => FutbList.Contains(d.ITEM_CODE ?? 0) || d.ITEM_CODE == null).ToList();
             //var x = db.SEC_MENUS.ToList().OrderBy(a => a.MENU_CODE);
          return titlesInIdList;

      }


这篇关于如何通过linq获取项目等于新项目列表的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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