i have done it guys with expression. This article helped me http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/8b8f766c-c7a2-4b29-a075-2db80a65a0fe/[^] i replaced the return statement to this ; System.Linq.Expressions.ParameterExpression paramExp = System.Linq.Expressions.Expression.Parameter(typeof(TEntity), "ParamExp"); System.Linq.Expressions.Expression<Func<TEntity, bool>> predicate = System.Linq.Expressions.Expression.Lambda<Func<TEntity, bool>>( System.Linq.Expressions.Expression.Equal( System.Linq.Expressions.Expression.Property(paramExp, pInfo), System.Linq.Expressions.Expression.Constant(PrimaryKey)), paramExp); return context.GetTable<TEntity>().Where(predicate).First();