Quantcast
Channel: CRM Development 論壇
Viewing all articles
Browse latest Browse all 10280

LINQ where clause on an option set value

$
0
0

I want to write a LINQ query to return a list of users who are administer teams which have a particular property. So in the team I have a custom field "MyProperty" which is defined to have values of "Yes" or "No" and I then try to write a linq query which is something like ...

// a query to list all teams
var queryTeams = from t in ctx.TeamSet
                 join u in ctx.SystemUserSet on t.AdministratorId.Id equals u.SystemUserId.Value
                 where t.GetAttributeValue<String>("MyProperty") == "Yes"
                 select new { t.Name, t.AdministratorId, u.FullName, t.qubic_Manageleave };

I have of course tried multiple variants of this and they all fail with a similar problem that GetAttributeValue returns the integer of the underlying lookup list and not the string value it corresponds to. Now in traditional SQL this is trivial so presumably there should be some relatively simple way of doing this or am I missing something really simple here. All I really want is the LINQ equivalent of;

SELECT somfields
FROM teams t
LEFT JOIN users u on t.AdministratorID = u.Id
LEFT JOIN mylookup lu on t.MyProperty = lu.Id
WHERE lu.value = "Yes"

Is there a simple way to do that?



Viewing all articles
Browse latest Browse all 10280


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>