Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, After a gap, again I entered to Visual C++ 2010. Now my intention is to prepare a LINQ Query to select a distinct value from a datatable

In C# My Query

var ProjLnkQry = (from P in MyClass1.ProjTbl.AsEnumerable() select P["proj_name"]).Distinct().ToList();


The above query I try to convert it into VIsual C++

C++
auto DistDepQry=(from v1 in MyGlobalData::ProjectTbl::AsEnumaerable() select v1["depart_name"])->Distinct()->ToList();


But not succeeded....Thanks for the ideas...
Posted
Comments
Thomas Daniels 28-Oct-13 11:10am    
Which error do yo get?

1 solution

Hi
Distinct:

C#
//distinct objects
List<objects> listObjects = (from obj in db.Objects                             
                             select obj).Distinct().ToList();
//distinct based on a specific propertie (in this case Mobile and Fax)
List<Objects> listObjects = (from obj in db.Objects                             
                                select obj).GroupBy(n => new {n.Mobile, n.Fax})
                                           .Select(g => g.FirstOrDefault())
                                           .ToList();

</objects>


Hope it helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900