Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insensitive Contains #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Kendo.DynamicLinq/Filter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public class Filter
{"startswith", "StartsWith"},
{"endswith", "EndsWith"},
{"contains", "Contains"},
{"doesnotcontain", "Contains"}
{"doesnotcontain", "Contains"},
{"insensitivecontains", "ToLower().Contains"}
};

/// <summary>
Expand Down Expand Up @@ -83,7 +84,7 @@ private void Collect(IList<Filter> filters)
}
else
{
filters.Add(this);
//filters.Add(this);
}
}

Expand Down Expand Up @@ -112,6 +113,12 @@ public string ToExpression(IList<Filter> filters)
return String.Format("{0}.{1}(@{2})", Field, comparison, index);
}

if (Operator == "insensitivecontains")
{
Value = Value.ToString().ToLower();
return String.Format("{0}.{1}(@{2})", Field, comparison, index);
}

return String.Format("{0} {1} @{2}", Field, comparison, index);
}
}
Expand Down
9 changes: 7 additions & 2 deletions Kendo.DynamicLinq/Kendo.DynamicLinq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<AssemblyName>Kendo.DynamicLinq</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -35,8 +39,9 @@
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Linq.Dynamic">
<HintPath>..\packages\System.Linq.Dynamic.1.0.0\lib\net40\System.Linq.Dynamic.dll</HintPath>
<Reference Include="System.Linq.Dynamic, Version=1.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\ImmigrationCRM\iCRM\ASPNET\packages\System.Linq.Dynamic.1.0.4\lib\net40\System.Linq.Dynamic.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.Serialization" />
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions Kendo.DynamicLinq/QueryableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ private static IQueryable<T> Filter<T>(IQueryable<T> queryable, Filter filter)
// Collect a flat list of all filters
var filters = filter.All();

// Get all filter values as array (needed by the Where method of Dynamic Linq)
// Create a predicate expression e.g. Field1 = @0 And Field2 > @1
string predicate = filter.ToExpression(filters);

// Get all filter values as array (needed by the Where method of Dynamic Linq)
var values = filters.Select(f => f.Value).ToArray();

// Create a predicate expression e.g. Field1 = @0 And Field2 > @1
string predicate = filter.ToExpression(filters);

// Use the Where method of Dynamic Linq to filter the data
queryable = queryable.Where(predicate, values);
}
Expand Down
2 changes: 1 addition & 1 deletion Kendo.DynamicLinq/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Linq.Dynamic" version="1.0.0" targetFramework="net40" />
<package id="System.Linq.Dynamic" version="1.0.4" targetFramework="net40" />
</packages>