Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.50 KB | None | 0 0
  1.     Public Function GetByID(Of T As Class)(ByVal pk As Object) As T
  2.         Dim itemParam = Expression.Parameter(GetType(T), "item")
  3.         Return GetTable(Of T).Single(
  4.             Expression.Lambda(Of Func(Of T, Boolean))(
  5.                 Expression.Equal(
  6.                     Expression.Property(itemParam, GetPrimaryKeyName(Of T)),
  7.                     Expression.Constant(pk)
  8.                     ),
  9.                 New ParameterExpression() {itemParam}
  10.                 )
  11.             )
  12.     End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement