Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ToList.Where not producing expected results
Message
From
29/10/2012 19:07:52
 
 
To
All
General information
Forum:
ASP.NET
Category:
LINQ
Title:
ToList.Where not producing expected results
Miscellaneous
Thread ID:
01556016
Message ID:
01556016
Views:
44
Hi,

another developer who I'v e helped in the past has asked me to help him work out why he is not getting the expected data with the following code:
@foreach (var claims in Model.Claims.ToList().Where(w => w.memberid == User.Identity.Name.Substring(User.Identity.Name.IndexOf('(') + 1, (User.Identity.Name.IndexOf(')') - 1) - User.Identity.Name.IndexOf('('))) )
                    {
                        var uid = User.Identity.Name.Substring(User.Identity.Name.IndexOf('(') + 1, (User.Identity.Name.IndexOf(')') - 1) - User.Identity.Name.IndexOf('('));
                        var mid = claims.memberid;
                        if (uid == mid)
                        {
                            <tr class="odd-row">
                                <td>N/A</td>
                                <td>@claims.healthplanid</td>
                                <td>@claims.claimnumber</td>
Unfortunately I do not have a clue (having never used LINQ, which is what I think this code is using) but I've asked him how come the first line (with the ToList().Where) doesn't just pull out the correct set of records and he doesn't know.

The User.Identity.Name should contain a string like this: Frank Cazabon (214-00-0121)

But apparently it is pulling out lots of other data but not the expected set.

Can any one explain why?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Next
Reply
Map
View

Click here to load this message in the networking platform