Users Pricing

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 2161 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?


1 Answers