i have this table
**ID           CityCode             Price**
1             ABB                  100
2             CAB                  160
3             CAB                  340
4             TRE                  800
5             ABB                  770
6             TRE                  900
7             ABB                  500
I want write down a query(linq) which will return the following result as show the code below
CityCo开发者_如何学Gode
   ABB
   CAB
   TRE
i want select a list with only the CityCode without duplicate record, How can i do it with linq to sql ?
Thanks so much for your attention,
have a good time, Cheers
It sounds like you want Distinct()
var cityCodes = cities.Select(x => x.CityCode).Distinct();
That's not the same as retrieving a single record (as per your title) though. If this isn't what you're after, please give us more information.
Try using .Distinct():
var city = (from ci in dc.citieis select ci.CityCode).Distinct();
I hope this is what you're looking for; please try to make your question more explainatory. For more on LINQ you can checkout my blog here : linqtoSQL
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论