Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat return type do I make this method?
    primarykey
    data
    text
    <p>Ive got the following code that returns a set of results from the CRM and then I bind it to a dropDownList:</p> <pre><code> var context = new XrmServiceContext(); var contacts1 = ( from c in context.ContactSet join m in context.py3_membershipSet on c.ContactId equals m.py3_Member.Id where m.statuscode.Value == 1 orderby c.LastName select new { ContactId = c.ContactId, FirstName = c.FirstName, LastName = c.LastName, BranchCode = c.py3_BranchArea, Branch = (c.FormattedValues != null &amp;&amp; c.FormattedValues.Contains("py3_brancharea") ? c.FormattedValues["py3_brancharea"] : "N/a"), JobTitle = c.JobTitle, Organisation = (c.ParentCustomerId != null ? c.ParentCustomerId.Name : "N/a"), joinedAsCode = c.py3_SOLACEMemberJoinedAs, JoinedAs = (c.FormattedValues != null &amp;&amp; c.FormattedValues.Contains("py3_solacememberjoinedas") ? c.FormattedValues["py3_solacememberjoinedas"] : "N/a"), Expertise = (c.py3_SOLACEMemberAreasofExpertise != null &amp;&amp; c.py3_SOLACEMemberAreasofExpertise.Trim() != String.Empty ? c.py3_SOLACEMemberAreasofExpertise : "N/a") } ); </code></pre> <p>However, I need to make this into a method so that I can can call this set of results and do some LINQ on the returned data depending on some other criteria.</p> <p>Im new to using LINQ and the whole idea of 'var' to contain the result set, hence Im lost as to what type to make the method:</p> <pre><code> protected static **something** getContacts() { var context = new XrmServiceContext(); var contacts1 = ( from c in context.ContactSet join m in context.py3_membershipSet on c.ContactId equals m.py3_Member.Id where m.statuscode.Value == 1 orderby c.LastName select new { ContactId = c.ContactId, FirstName = c.FirstName, LastName = c.LastName, BranchCode = c.py3_BranchArea, Branch = (c.FormattedValues != null &amp;&amp; c.FormattedValues.Contains("py3_brancharea") ? c.FormattedValues["py3_brancharea"] : "N/a"), JobTitle = c.JobTitle, Organisation = (c.ParentCustomerId != null ? c.ParentCustomerId.Name : "N/a"), joinedAsCode = c.py3_SOLACEMemberJoinedAs, JoinedAs = (c.FormattedValues != null &amp;&amp; c.FormattedValues.Contains("py3_solacememberjoinedas") ? c.FormattedValues["py3_solacememberjoinedas"] : "N/a"), Expertise = (c.py3_SOLACEMemberAreasofExpertise != null &amp;&amp; c.py3_SOLACEMemberAreasofExpertise.Trim() != String.Empty ? c.py3_SOLACEMemberAreasofExpertise : "N/a") } ); return contacts; } </code></pre> <p>What type should it be? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload