如何在sql Server 2005的linq中检查唯一性 [英] how to check unique in linq with sql server 2005

查看:75
本文介绍了如何在sql Server 2005的linq中检查唯一性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个单独的bool类型函数以进行唯一检查..

i want to write a separate bool type function for check unique..

推荐答案

List<T> withDupes = LoadSomeData();
List<T> noDupes = withDupes.Distinct().ToList();


尝试一下,

try this,

List<Product> products = GetProductList();
   var categoryNames = (
       from p in products
       select p.Category)
       .Distinct();







or

int[] factorsOf300 = { 2, 2, 3, 5, 5 };
    var uniqueFactors = factorsOf300.Distinct();



一切顺利.



All the best.


这篇关于如何在sql Server 2005的linq中检查唯一性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆