diff --git a/Kendo.DynamicLinq.Tests/Kendo.DynamicLinq.Tests.csproj b/Kendo.DynamicLinq.Tests/Kendo.DynamicLinq.Tests.csproj deleted file mode 100644 index 8732a8b..0000000 --- a/Kendo.DynamicLinq.Tests/Kendo.DynamicLinq.Tests.csproj +++ /dev/null @@ -1,70 +0,0 @@ - - - - - Debug - AnyCPU - {92FF629E-8872-4CCE-B558-F9FE437DDA86} - Library - Properties - Kendo.DynamicLinq.Tests - Kendo.DynamicLinq.Tests - v4.0 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - - - - - - - - - - - - - - - - - - - - - - - {2bd75d53-e0ea-4995-8b0f-60ad709945ac} - Kendo.DynamicLinq - - - - - \ No newline at end of file diff --git a/Kendo.DynamicLinq.Tests/Properties/AssemblyInfo.cs b/Kendo.DynamicLinq.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 076d231..0000000 --- a/Kendo.DynamicLinq.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Kendo.DynamicLinq.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Kendo.DynamicLinq.Tests")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("59ff0f3d-edff-45c3-8e15-691d02dcd302")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kendo.DynamicLinq.Tests/SerializationTests.cs b/Kendo.DynamicLinq.Tests/SerializationTests.cs deleted file mode 100644 index a023ad9..0000000 --- a/Kendo.DynamicLinq.Tests/SerializationTests.cs +++ /dev/null @@ -1,52 +0,0 @@ -using NUnit.Framework; -using System.IO; -using System.Linq; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Json; -using System.Text; - -namespace Kendo.DynamicLinq.Tests -{ - [KnownType(typeof(Person))] - public class Person - { - public int Age { get; set; } - } - - [TestFixture] - public class SerializationTests - { - [Test] - public void DataContractJsonSerializerSerializesEmptyAggregates() - { - using (var stream = new MemoryStream()) - { - var serializer = new DataContractJsonSerializer(typeof(DataSourceResult)); - - serializer.WriteObject(stream, new[] { "foo" }.AsQueryable().ToDataSourceResult(1, 0, null, null)); - - Assert.AreEqual("{\"Aggregates\":null,\"Data\":[\"foo\"],\"Total\":1}", Encoding.UTF8.GetString(stream.ToArray())); - } - } - - [Test] - public void DataContractJsonSerializerSerializesAggregates() - { - using (var stream = new MemoryStream()) - { - var serializer = new DataContractJsonSerializer(typeof(DataSourceResult), new [] { typeof (Person) }); - - var people = new[] { new Person { Age = 30 }, new Person { Age = 30 } }; - - serializer.WriteObject(stream, people.AsQueryable().ToDataSourceResult(1, 2, null, null, new [] { new Aggregator { - Aggregate = "sum", - Field = "Age" - } })); - - var json = Encoding.UTF8.GetString(stream.ToArray()).Replace("\"__type\":\"DynamicClass2:#\",", ""); - - Assert.AreEqual("{\"Aggregates\":{\"Age\":{\"sum\":60}},\"Data\":[],\"Total\":2}", json); - } - } - } -} diff --git a/Kendo.DynamicLinq.Tests/packages.config b/Kendo.DynamicLinq.Tests/packages.config deleted file mode 100644 index 139d513..0000000 --- a/Kendo.DynamicLinq.Tests/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Kendo.DynamicLinq/Filter.cs b/Kendo.DynamicLinq/Filter.cs index 76e4059..bdeb6c8 100644 --- a/Kendo.DynamicLinq/Filter.cs +++ b/Kendo.DynamicLinq/Filter.cs @@ -101,7 +101,12 @@ public string ToExpression(IList filters) int index = filters.IndexOf(this); string comparison = operators[Operator]; - + + if (this.Value.GetType().Equals(typeof(Guid))) + { + return String.Format("{0}.Equals(@{1})", Field, index); + } + if (Operator == "doesnotcontain") { return String.Format("!{0}.{1}(@{2})", Field, comparison, index); diff --git a/Kendo.DynamicLinq/Kendo.DynamicLinq.csproj b/Kendo.DynamicLinq/Kendo.DynamicLinq.csproj index 3c5fd88..d7d76eb 100644 --- a/Kendo.DynamicLinq/Kendo.DynamicLinq.csproj +++ b/Kendo.DynamicLinq/Kendo.DynamicLinq.csproj @@ -48,6 +48,7 @@ + diff --git a/Kendo.DynamicLinq/View.cs b/Kendo.DynamicLinq/View.cs new file mode 100644 index 0000000..d2d8390 --- /dev/null +++ b/Kendo.DynamicLinq/View.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Kendo.DynamicLinq +{ + public class View + { + public int Take { get; set; } + public int Skip { get; set; } + public List Sort { get; set; } + public Filter Filter { get; set; } + public List Aggregates { get; set; } + /// + /// Filter.Value alanında guid değerler strint Type olarak gözükebilir, bu fonksiyon Guid ama string alan FieldType'ları Guid Type olarak günceller. + /// + public void FieldTypeCheckAll() + { + List _filters = Filter.Filters.ToList(); + for (int i = 0; i < _filters.Count; i++) + { + _filters[i] = FieldTypeCheck(_filters[i]); + } + Filter.Filters = (IEnumerable)_filters; + Filter = FieldTypeCheck(Filter); + } + + public Filter FieldTypeCheck(Filter filter) + { + if (filter.Value == null) + { return filter; } + + Guid _guidResult; + if (Guid.TryParse(filter.Value.ToString(), out _guidResult)) + { + filter.Value = _guidResult; + } + return filter; + } + } +}