zoukankan      html  css  js  c++  java
  • 泛型中去掉指定字段重复的数据 dodo

    public partial class V_MyJoinedCloudRespository

    {

            public List<V_MyJoinedCloud> GetDistinctJoinedCloud(string cloudName,long ExpertId)
            {
                var lamd = from p in db.V_MyJoinedCloud
                           where p.Status == 1 && p.CompanyName.Contains(cloudName) && p.ExpertID==ExpertId
                           select p;

                List<V_MyJoinedCloud> list = new List<V_MyJoinedCloud>();
                if (lamd!=null&&lamd.Count()>0)
                {
                    list = lamd.ToList();
                    list = list.Distinct(new CompanyNameComparer()).ToList();
                }
                return list;
            }

    }

    public class CompanyNameComparer : IEqualityComparer<V_MyJoinedCloud>
        {
            public bool Equals(V_MyJoinedCloud x, V_MyJoinedCloud y)
            {
                if (x == null)
                    return y == null;
                return x.CompanyID == y.CompanyID;
            }

            public int GetHashCode(V_MyJoinedCloud obj)
            {
                if (obj == null)
                    return 0;
                return obj.CompanyID.GetHashCode();
            }
        }

  • 相关阅读:
    Eclipse 开发过程中利用 JavaRebel 提高效率
    数字转化为大写中文
    网页变灰
    解决QQ截图无法在PS中粘贴
    ORACLE操作表时”资源正忙,需指定nowait"的解锁方法
    网页常用代码
    SQL Server 2000 删除注册的服务器
    GridView 显示序号
    读取Excel数据到DataTable
    清除SVN版本控制
  • 原文地址:https://www.cnblogs.com/zgqys1980/p/3135388.html
Copyright © 2011-2022 走看看