Tag: generic method

具有自定义格式的C#Generic DateTime.ToString()

使用时: DateTime.ToString().Contains(“2016”) entity framework产生: CAST(DateValue AS nvarchar(max)) LIKE ‘%2016%’ 这使用默认的日期格式“mon dd yyyy hh:miAM(或PM)” 我想用“yyyy-mm-dd hh:mi:ss(24h)”,这可以通过以下方式获得: CONVERT(VARCHAR(max), DateValue, 20) LIKE ‘%2016%’ 我需要帮助将这种格式实现到现有的generics方法。 static Expression<Func> Expr(Expression<Func> source) { return source; } static MethodInfo GetMethod(this LambdaExpression source) { return ((MethodCallExpression)source.Body).Method; } static readonly MethodInfo Object_ToString = Expr((object x) => x.ToString()).GetMethod(); static readonly MethodInfo String_Contains = Expr((string x) => […]