zoukankan      html  css  js  c++  java
  • Linq中几个扩展方法的使用

    一个List 保存是ClassOrganization 的实体的信息

    依据某个ClassOrganization实体的ID在List中查找该实体,如:

    ClassOrganization org = orgList.Find(o=>o.Orgid==orgId);

    依据某个ClassOrganization实体的ID判断List中是否有该实体,如:

    orgList.Exists(o => o.Orgid == OrgID)

    //IList

     IList<Vanceinfo.Vsg.SystemAdmin.Entity.SmRole> roleList = BusinessCommon.Instance.GetUserRole(userCode, out userId);

    int count = roleList.Count<Vanceinfo.Vsg.SystemAdmin.Entity.SmRole>(r => r.RoleName == "公告管理"); //得到在列表中指定条件的角色数量

     if(count>0)

    {

      //证明有该记录

    }

    查找IList中的某个实体

    IList<BudgetData> list = bll.GetListByCondition(type, iBugetType);

    if (!string.IsNullOrEmpty(strYear))
                    {
                        strYearMonth = strYear + "-" + strMonth;

                        obj = list.SingleOrDefault<BudgetData>(b => b.YearMonth == strYearMonth && b.DepartCode == strDepart);
                    }

  • 相关阅读:
    安卓学习12
    安卓学习11
    安卓学习10
    安卓学习9
    Python3之json&pickle模块
    Mysql之基础sql语句
    Django模型层之单表操作
    创建Django项目与应用的两个命令
    windows命令行切换目录
    Django视图层之请求对象(request)和响应对象(HttpResponse)
  • 原文地址:https://www.cnblogs.com/vihone/p/1764645.html
Copyright © 2011-2022 走看看