适用Lambda对对象集合去重
-List Newlist = list.Select(x => new Model_DOC_MI_LIST_FOR_ORT
{
ORT_LIST_FLAG = x.ORT_LIST_FLAG,
ORT_LIST_ID = x.ORT_LIST_ID,
ASSOCIATED_MI_LIST_ID = x.ASSOCIATED_MI_LIST_ID,
ORT_LIST_VERSION_NUM = x.ORT_LIST_VERSION_NUM,
ORT_LIST_NUM = x.ORT_LIST_NUM,
CUSTOMER_NAME = x.CUSTOMER_NAME,
DUE_DATE = x.DUE_DATE,
ORT_LIST_PUB_DATE = x.ORT_LIST_PUB_DATE,
USER_FULLNAME = x.USER_FULLNAME,
USER_NAME_EN = x.USER_NAME_EN,
USER_DEPARTMENT = x.USER_DEPARTMENT,
ORT_LIST_EDITOR = x.ORT_LIST_EDITOR
}).Distinct(new Compare()).ToList();
private class Compare : IEqualityComparer
{
public bool Equals(Model_DOC_MI_LIST_FOR_ORT x, Model_DOC_MI_LIST_FOR_ORT y)
{
return x.ORT_LIST_ID == y.ORT_LIST_ID;
}
public int GetHashCode(Model_DOC_MI_LIST_FOR_ORT obj)
{
return obj.ORT_LIST_ID.GetHashCode();
}
}