码迷,mamicode.com
首页 > 其他好文 > 详细

Linq To Object多字段组合唯一校验

时间:2014-10-29 21:02:42      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   sp   div   art   log   ad   


1
.第一种方式 if(partsSalesOrderTypes.GroupBy(entity => new { entity.Name, entity.Code }).Any(array => array.Count() > 1)) { /*违反多字段唯一时,提示信息处理*/ return; } 2.第二种方式 var groupPrice = from price in this.PartsSpecialTreatyPrices group price by new { price.DealerId, //分组字段 price.PartsSalesCategoryId, //分组字段 price.SparePartId //分组字段 } into groups select new { count = groups.Count(), key = groups.Key }; if(groupPrice.Any(group => group.count > 1)) { /*违反多字段唯一时,提示信息处理*/ }

Linq To Object多字段组合唯一校验

标签:style   blog   color   ar   sp   div   art   log   ad   

原文地址:http://www.cnblogs.com/hornet/p/4060290.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!