Come ricavare un record con Entity Framework 4.1
Scritto da
Alessandro Mostarda il
lunedì 10 ottobre 2011
•
Linguaggio:
• Livello: 100
Per ricavare l'istanza di un oggetto, relativo al record di una
tabella, tramite la chiave si può usare il nuovo metodo FIND
dell'oggetto DBSet
C#
var key = 2;
using (var ctx = new CtxEntities())
{
var fattura = ctx.Fatture.Find(key);
}
VB.NET
Dim key As Integer = 2
Using ctx As New CtxEntities
Dim fattura = ctx.fatture.Find(key)
End Using
Tags: Linq,Entity Framework,EF4,ef