Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save matt-hensley/9a3df25430c789702dd37d87c5d11fb8 to your computer and use it in GitHub Desktop.
Save matt-hensley/9a3df25430c789702dd37d87c5d11fb8 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
//using Dapper.FastCrud;
//using Dapper.FastCrud.Configuration;
using Dapper.FastCrud.Configuration.StatementOptions;
//using Dapper.FastCrud.Configuration.StatementOptions.Builders;
//using Dapper.FastCrud.Mappings;
namespace DapperSample {
public static class SqlExtensions {
public static TStatementOptionsBuilder Where<TEntity, TStatementOptionsBuilder, TValue>(this IConditionalSqlStatementOptionsOptionsSetter<TEntity, TStatementOptionsBuilder> sql,
Expression<Func<TEntity, TValue>> expression,
string op,
TValue value) {
var name = StaticReflection.GetMemberName(expression);
return SqlExtensions.Where(sql, name, op, value);
}
public static TStatementOptionsBuilder Where<TEntity, TStatementOptionsBuilder, TValue>(this IConditionalSqlStatementOptionsOptionsSetter<TEntity, TStatementOptionsBuilder> sql,
string name,
string op,
TValue value) {
return sql.Where($"{name:C}{op}{value}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment