Skip to content

Commit

Permalink
Added apply to method
Browse files Browse the repository at this point in the history
  • Loading branch information
mcintyre321 committed Sep 5, 2014
1 parent 9edbb23 commit c07c996
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions LinqToAnything/LinqToAnything.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Linq.Dynamic">
<HintPath>..\packages\System.Linq.Dynamic.1.0.2\lib\net40\System.Linq.Dynamic.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down
25 changes: 23 additions & 2 deletions LinqToAnything/QueryInfo.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Net.Mail;

using System.Linq.Dynamic;
namespace LinqToAnything
{
/// <summary>
Expand Down Expand Up @@ -41,7 +42,27 @@ public QueryInfo Clone()
Clauses = this.Clauses.Select(c => c.Clone()).ToList()
};
}


public IQueryable<T> ApplyTo<T>(IQueryable<T> q)
{
var qi = this;
foreach (var clause in qi.Clauses)
{
q = q.Where((Expression<Func<T, bool>>)clause.Expression);
}
if (qi.OrderBy != null)
{
q = q.OrderBy(qi.OrderBy.ToString());
}

if (qi.Skip > 0) q = q.Skip(qi.Skip);

if (qi.Take != null) q = q.Take(qi.Take.Value);



return q;
}
}


Expand Down
1 change: 1 addition & 0 deletions LinqToAnything/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="QueryInterceptor" version="0.2" targetFramework="net45" />
<package id="System.Linq.Dynamic" version="1.0.2" targetFramework="net45" />
</packages>

0 comments on commit c07c996

Please sign in to comment.