I have a Linq statement that has to check which Client is connected to which user
public List<Client_Dto> GetClientByBehandelaar(string loggedInUserId)
{
try
{
int userID = Convert.ToInt32(loggedInUserId);
nestorDBDataContext db = new nestorDBDataContext();
var result =
(from relaties in db.tbl_Relaties
where relaties.ID_Persoon == userID
select new Client_Dto()
{
ID = relaties.NestorNrCliënt
}).ToList();
List<Client_Dto> clienten = result;
return clienten;
}
catch (Exception e)
{
throw new ArgumentException("GetClientByBehandelaar Failed " + e);
}
}
but it only selects one even when there are 87 more in the DB with the same userID. I’ve been staring myself to death on this one .. Can someone help
I tried it here and your code works:
Maybe you need to look at this boolean comarison
ID_Persoon == userIDUse Debug.WriteLine to output the results for you.