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