Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7505
  • 博文数量: 11
  • 博客积分: 230
  • 博客等级: 二等列兵
  • 技术积分: 120
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-11 16:03
文章分类

全部博文(11)

文章存档

2011年(11)

我的朋友
最近访客

分类: 嵌入式

2011-02-14 09:48:48

1.在datatable中获取最大值
 var maxValue = _roleHandler.FrmUsers.DsESssUserRole.Roles.Rows.OfType().Select(row => row["RoleID"]).Max();
2.在datatable中获取指定值没有转换成Ienumable?
var name = from device in deviceDt where device.DeviceID == addDeviceId[i] select device.Name;
3.用except获取集合差集(对象的集合) 类继承IEquatable接口
 List value = rightsList.Except(currentRights).ToList(); Except方法
  public class Rights:IEquatable
    {
        private int rightCode;
        private int rightType;
        private int rightItemId;
       #region IEquatable 成员
        bool IEquatable.Equals(Rights other)
        {
           if(object.ReferenceEquals(other,null)) return false;
           if (object.ReferenceEquals(this, other)) return true;
           return rightCode.Equals(other.rightCode) && rightType.Equals(other.rightType) && rightItemId.Equals(other.rightItemId);
        }
       public override int GetHashCode()
       {
           int code = rightCode.GetHashCode();
           int type = rightType.GetHashCode();
           int item = rightItemId.GetHashCode();
           return code ^ type ^ item;
       }
        #endregion
    }
 3.linq Except()方法取集合差集  类型转换
 List addList = listRightId.Except(query) as System.Collections.Generic.List;
 
阅读(284) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~