Last post Oct 12, 2015 07:48 AM by wavemaster
Oct 10, 2015 11:18 PM|wavemaster|LINK
Sorry, don't know what the name is.
This is my code.
var cshoeinfo = (from cs in client.ClientShoes
where cs.ProviderId == providerid select cs).FirstOrDefault());
Now I need to put it inside an if statement, how do I declare this?
I am used to doing this:
This causes "cannot covert type 'ClientShoe to Systems.Collection.Generic.dynamic."
Oct 11, 2015 03:59 PM|Mikesdotnetting|LINK
ClientShoe cshoeinfo = null;
cshoinfo = client.ClientShoes.FirstOrDefault(cs => cs.ProviderId == providerid);
Note: I have used method syntax for the query. You can use your version which is query syntax. The result is the same.
Another note, if you are unsure that type your LINQ query returns, hover over the var keyword in VS, It will tell you.
A final note, the error message also told you what the data type of cshoeinfo actually is.
Oct 11, 2015 09:58 PM|wavemaster|LINK
It said class.
Oct 12, 2015 02:01 AM|Mikesdotnetting|LINK
It should also have said ClientShoe.
Is your issue still unresolved?
Oct 12, 2015 07:48 AM|wavemaster|LINK
Must have hit 'mark as answer" twice.