System.Linq.Dynamic

http://dynamiclinq.codeplex.com/

10万回 用动态表达式 0.19s ,普通Lamba 0.02s,效率还可以

/*
User: Peter
Date: 2016/4/12
Time: 14:20 */
using System;
using System.Linq.Dynamic;
using System.Linq.Expressions;
using NUnit.Framework; namespace Penseesoft.Utility.Tester.Daily
{
public class TestInt
{
public int Value
{
get;
set;
}
}
[TestFixture]
public class Test111
{
[Test]
public void TestMethod()
{ Expression<Func<TestInt,bool>> e = DynamicExpression.ParseLambda<TestInt,bool>("Value%2==0");
Func<TestInt,bool> b = e.Compile();
TestInt pi = new TestInt();
for(int i = ;i<;i++)
{
pi.Value = i;
b(pi);
}
} [Test()]
public void Test1()
{
Func<int,bool> b = i=>i%==;
for(int i = ;i<;i++)
{
b(i);
}
}
}
}
上一篇:Asp.Net的两种开发方式


下一篇:Stakeholder Risk Management