¡@

Home 

c# Programming Glossary: itemparameter

C# LINQ to SQL: Refactoring this Generic GetByID method

http://stackoverflow.com/questions/735140/c-sharp-linq-to-sql-refactoring-this-generic-getbyid-method

public T GetByID int id var dbcontext DB var itemParameter Expression.Parameter typeof T item var whereExpression Expression.Lambda.. Func T bool Expression.Equal Expression.Property itemParameter typeof T .GetPrimaryKey .Name Expression.Constant id new.. T .GetPrimaryKey .Name Expression.Constant id new itemParameter return dbcontext.GetTable T .Where whereExpression .Single..