packages/System.Linq.Dynamic.Core.1.0.7.13/src/System.Linq.Dynamic.Core/DynamicQueryableExtensions.cs
(开头部分) 95KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System.Collections.Generic;
using System.Collections;
using System.Globalization;
using System.Linq.Dynamic.Core.Exceptions;
#if !(WINDOWS_APP45x || SILVERLIGHT)
using System.Diagnostics;
#endif
using System.Linq.Dynamic.Core.Extensions;
using System.Linq.Dynamic.Core.Validation;
using System.Linq.Expressions;
using System.Reflection;
using JetBrains.Annotations;
#if WINDOWS_APP
using System;
using System.Linq;
#endif
namespace System.Linq.Dynamic.Core
{
/// <summary>
/// Provides a set of static (Shared in Visual Basic) methods for querying data structures that implement <see cref="IQueryable"/>.
/// It allows dynamic string based querying. Very handy when, at compile time, you don't know the type of queries that will be generated,
/// or when downstream components only return column names to sort and filter by.
/// </summary>
public static class DynamicQueryableExtensions
{
#if !(WINDOWS_APP45x || SILVERLIGHT)
private static readonly TraceSource TraceSource = new TraceSource(typeof(DynamicQueryableExtensions).Name);
#endif
private static readonly Func<MethodInfo, bool> PredicateParameterHas2 = mi => mi.GetParameters()[1].ToString().Contains("Func`2");
private static Expression OptimizeExpression(Expression expression)
{
if (ExtensibilityPoint.QueryOptimizer != null)
{
var optimized = ExtensibilityPoint.QueryOptimizer(expression);
#if !(WINDOWS_APP45x || SILVERLIGHT)
if (optimized != expression)
{
TraceSource.TraceEvent(TraceEventType.Verbose, 0, "Expression before : {0}", expression);
TraceSource.TraceEvent(TraceEventType.Verbose, 0, "Expression after : {0}", optimized);
}
#endif
return optimized;
}
return expression;
}
#region Aggregate
/// <summary>
/// Dynamically runs an aggregate function on the IQueryable.
/// </summary>
/// <param name="source">The IQueryable data source.</param>
/// <param name="function">The name of the function to run. Can be Sum, Average, Min or Max.</param>
/// <param name="member">The name of the property to aggregate over.</param>
/// <returns>The value of the aggregate function run over the specified property.</returns>
public static object Aggregate([NotNull] this IQueryable source, [NotNull] string function, [NotNull] string member)
{
后面还有 1705 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
