LambdaToSql/LambdaParser/LambdaRouter.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
namespace LambdaToSql
{
internal class LambdaRouter
{
/// <summary>
/// 返回结果
/// </summary>
public string Result { get; set; }
/// <summary>
/// sql参数集合
/// </summary>
public List<LambdaToSql.EntityModel.DataParameter> Parameters { get; set; }
/// <summary>
/// 带sql参数的构造函数
/// </summary>
/// <param name="parameters"></param>
public LambdaRouter(List<LambdaToSql.EntityModel.DataParameter> parameters = null)
{
this.Parameters = parameters;
if (this.Parameters == null)
{
this.Parameters = new List<LambdaToSql.EntityModel.DataParameter>();
}
}
/// <summary>
/// 解析表达式
/// </summary>
/// <param name="exp"></param>
/// <returns></returns>
public string ExpressionRouter(Expression exp)
{
var obj = new LambdaParser.ParserBuilder()
{
ArgumentsStartIndex = this.Parameters.Count
};
obj.InitBuild(exp);
this.Result = obj.Result;
foreach (DictionaryEntry item in obj.Arguments)
{
if (item.Value == null)
{
var rex = "\\((.*?)" + item.Key.ToString() + "\\)";
var arr = Regex.Matches(this.Result, rex);
foreach (var _temp in arr)
{
var name = "";
var value = "";
后面还有 22 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
