forum

home / developersection / forums / how do i get a single row from a linq expression in c#?

How do I get a single row from a linq expression in C#?

Norman Reedus 2003 17-Feb-2015

This code is supposed to get a DateTime from a linq expression.

DateTime orderDate = (from order in db.Orders where order.Id == orderRules.OrderId select order.DatumTijd).SingleOrDefault();
Instead I get this errorMessage:
'System.Data.Entity.Core.EntityCommandExecutionException' occurred in EntityFramework.SqlServer.dll but was not handled in user code

What could be wrong?


c# c#  linq 
Updated on 17-Feb-2015
Can you answer this question?

Answer

1 Answers

Liked By