Reputation: 199
I am using this code to get some data from my database in my controller
var NewAspNetId = from a in db.CVVersjon
where a.CVVersjonId.Equals(Id)
select a.CVVersjonId;
And the value I get back is
SELECT
[Extent1].[CVVersjonId] AS [CVVersjonId]
FROM
[dbo].[CVVersjon] AS [Extent1]
WHERE
[Extent1].[CVVersjonId] = @p__linq__0
What am I doing wrong?
Upvotes: 0
Views: 806
Reputation: 151720
That is not the value you get back. That is the debugger showing you the query.
In order to execute the query and materialize the result, you need to enumerate NewAspNetId
:
foreach (var versionId in NewAspNetId)
{
// do something with versionId
}
Or, if you're sure that query returns [0..1] records:
var newId = NewAspNetId.FirstOrDefault();
Upvotes: 1