Quantcast
Channel: Forum CRM Development
Viewing all articles
Browse latest Browse all 1000

Retrieve only StateCode via LINQ

$
0
0

I've written the following LINQ query that is attempting to return the StateCode values for all Contact records that match a particular last name

var cs = (from c in myCTX.ContactSet
          where c.LastName == "Smith"
          select new Contact
          {
              StateCode = c.StateCode
          });
foreach (Contact c in cs)
{                                       
}

However, I'm receiving the following error in my code on the StateCode = c.StateCodeline:

Property or indexer 'StateCode' cannot be assigned to -- it is read only

Any idea how I can get around this error? 

Thank you


Viewing all articles
Browse latest Browse all 1000

Trending Articles



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