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);
                    }

  • 相关阅读:
    C#反射(一)
    找回密码
    常用的webservice接口 .
    C# 反射应用技术
    Delphi简介
    C#程序思想简介
    如何跨线程访问window控件
    C#如何判断某个文件夹是否为共享,访问权限为只读
    Delphi基础
    Web Service接口
  • 原文地址:https://www.cnblogs.com/vihone/p/1764645.html
Copyright © 2011-2022 走看看