Skip to content

Instantly share code, notes, and snippets.

@jnm2
Created July 1, 2016 18:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnm2/f1daecadfb9c986a3d3de5ac9cd72f0d to your computer and use it in GitHub Desktop.
Save jnm2/f1daecadfb9c986a3d3de5ac9cd72f0d to your computer and use it in GitHub Desktop.
public static class DbFunctionExpressions
{
private static readonly MethodInfo BinaryDummyMethodInfo = typeof(DbFunctionExpressions).GetMethod(nameof(BinaryDummyMethod), BindingFlags.Static | BindingFlags.NonPublic);
private static bool BinaryDummyMethod(byte[] left, byte[] right)
{
throw new NotImplementedException();
}
public static Expression BinaryLessThan(Expression left, Expression right)
{
if (left.Type != typeof(byte[])) throw new ArgumentException("Operands must be of type byte[].", nameof(left));
if (right.Type != typeof(byte[])) throw new ArgumentException("Operands must be of type byte[].", nameof(right));
return Expression.LessThan(left, right, false, BinaryDummyMethodInfo);
}
public static Expression BinaryLessThanOrEqual(Expression left, Expression right)
{
if (left.Type != typeof(byte[])) throw new ArgumentException("Operands must be of type byte[].", nameof(left));
if (right.Type != typeof(byte[])) throw new ArgumentException("Operands must be of type byte[].", nameof(right));
return Expression.LessThanOrEqual(left, right, false, BinaryDummyMethodInfo);
}
public static Expression BinaryGreaterThan(Expression left, Expression right)
{
if (left.Type != typeof(byte[])) throw new ArgumentException("Operands must be of type byte[].", nameof(left));
if (right.Type != typeof(byte[])) throw new ArgumentException("Operands must be of type byte[].", nameof(right));
return Expression.GreaterThan(left, right, false, BinaryDummyMethodInfo);
}
public static Expression BinaryGreaterThanOrEqual(Expression left, Expression right)
{
if (left.Type != typeof(byte[])) throw new ArgumentException("Operands must be of type byte[].", nameof(left));
if (right.Type != typeof(byte[])) throw new ArgumentException("Operands must be of type byte[].", nameof(right));
return Expression.GreaterThanOrEqual(left, right, false, BinaryDummyMethodInfo);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment