src/EasyFrameWork/LINQ/Query.cs
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/* http://www.zkea.net/
* Copyright (c) ZKEASOFT. All rights reserved.
* http://www.zkea.net/licenses */
using System;
using System.Collections.ObjectModel;
using System.Linq.Expressions;
using System.Reflection;
namespace Easy.LINQ
{
public class Query
{
public enum Operators
{
None = 0,
Equal = 1,
GreaterThan = 2,
GreaterThanOrEqual = 3,
LessThan = 4,
LessThanOrEqual = 5,
Contains = 6,
StartWith = 7,
EndWidth = 8,
Range = 9
}
public enum Condition
{
OrElse = 1,
AndAlso = 2
}
public string Name { get; set; }
public Operators Operator { get; set; }
public object Value { get; set; }
public object ValueMin { get; set; }
public object ValueMax { get; set; }
}
public class QueryCollection : Collection<Query>
{
public Expression<Func<T, bool>> AsExpression<T>(Query.Condition? condition = Query.Condition.OrElse) where T : class
{
Type targetType = typeof(T);
TypeInfo typeInfo = targetType.GetTypeInfo();
var parameter = Expression.Parameter(targetType, "m");
Expression expression = null;
Func<Expression, Expression, Expression> Append = (exp1, exp2) =>
{
if (exp1 == null)
{
return exp2;
}
return (condition ?? Query.Condition.OrElse) == Query.Condition.OrElse ? Expression.OrElse(exp1, exp2) : Expression.AndAlso(exp1, exp2);
};
foreach (var item in this)
{
var property = typeInfo.GetProperty(item.Name);
if (property == null ||
!property.CanRead ||
(item.Operator != Query.Operators.Range && item.Value == null) ||
后面还有 107 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。