├── .gitattributes
├── .gitignore
├── LICENSE.txt
├── LinqToQueryString.IntegrationTests
├── App.config
├── Exceptions.cs
├── LinqToQueryString.IntegrationTests.Sql.csproj
├── Properties
│ └── AssemblyInfo.cs
├── SqlCollectionAggregates.cs
├── SqlFiltering.cs
├── SqlFunctions.cs
├── SqlInlineCount.cs
├── SqlPagingAndOrdering.cs
├── SqlProjection.cs
├── TestDbContext.cs
└── packages.config
├── LinqToQueryString.Tests
├── ComplexClass.cs
├── ConcreteClass.cs
├── IndexedClass.cs
├── InstanceBuilders.cs
├── LinqToQueryString.Tests.csproj
├── Properties
│ └── AssemblyInfo.cs
└── RandomDataGenerators.cs
├── LinqToQueryString.UnitTests
├── CollectionAggregates.cs
├── Dynamics.cs
├── Exceptions.cs
├── Filtering.cs
├── Functions.cs
├── InlineCount.cs
├── LinqToQueryString.UnitTests.csproj
├── Options.cs
├── PagingAndOrdering.cs
├── Projection.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── LinqToQuerystring.Core.sln
├── LinqToQuerystring.Demo.Nancy
├── Bootstrapper.cs
├── LinqToQuerystring.Demo.Nancy.csproj
├── Models
│ └── Movie.cs
├── MoviesModule.cs
├── Properties
│ └── AssemblyInfo.cs
├── Web.Debug.config
├── Web.Release.config
├── Web.config
└── packages.config
├── LinqToQuerystring.Demo
├── App_Start
│ ├── BundleConfig.cs
│ ├── FilterConfig.cs
│ ├── RouteConfig.cs
│ └── WebApiConfig.cs
├── Content
│ └── Site.css
├── Controllers
│ ├── HomeController.cs
│ └── ValuesController.cs
├── Filters
│ └── ApiExceptionFilterAttribute.cs
├── Global.asax
├── Global.asax.cs
├── Images
│ ├── accent.png
│ ├── bullet.png
│ ├── heroAccent.png
│ ├── orderedList0.png
│ ├── orderedList1.png
│ ├── orderedList2.png
│ ├── orderedList3.png
│ ├── orderedList4.png
│ ├── orderedList5.png
│ ├── orderedList6.png
│ ├── orderedList7.png
│ ├── orderedList8.png
│ └── orderedList9.png
├── LinqToQuerystring.Demo.csproj
├── Models
│ └── Movie.cs
├── Properties
│ ├── AssemblyInfo.cs
│ └── PublishProfiles
│ │ ├── linqtoquerystring - FTP.pubxml
│ │ └── linqtoquerystring - Web Deploy.pubxml
├── Scripts
│ ├── _references.js
│ ├── jquery-1.10.1.js
│ ├── jquery-1.10.1.min.js
│ ├── jquery-ui-1.8.24.js
│ ├── jquery-ui-1.8.24.min.js
│ ├── jquery.odatafilterui-0.1.2.js
│ ├── jquery.odatafilterui-0.1.2.min.js
│ ├── jquery.unobtrusive-ajax.js
│ ├── jquery.unobtrusive-ajax.min.js
│ ├── jquery.validate-vsdoc.js
│ ├── jquery.validate.js
│ ├── jquery.validate.min.js
│ ├── jquery.validate.unobtrusive.js
│ ├── jquery.validate.unobtrusive.min.js
│ ├── knockout-2.2.1.debug.js
│ ├── knockout-2.2.1.js
│ └── modernizr-2.6.2.js
├── Views
│ ├── Home
│ │ └── Index.cshtml
│ ├── Shared
│ │ ├── Error.cshtml
│ │ └── _Layout.cshtml
│ ├── Web.config
│ └── _ViewStart.cshtml
├── Web.Debug.config
├── Web.Release.config
├── Web.config
├── favicon.ico
└── packages.config
├── LinqToQuerystring.EntityFramework
├── App.config
├── Configuration.cs
├── ExpandNode.cs
├── LinqToQuerystring.EntityFramework.csproj
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── LinqToQuerystring.IntegrationTests.EntityFramework
├── App.config
├── LinqToQuerystring.IntegrationTests.EntityFramework.csproj
├── Properties
│ └── AssemblyInfo.cs
├── SqlExpand.cs
└── packages.config
├── LinqToQuerystring.IntegrationTests.Mongo
├── ConcreteMongoClass.cs
├── Exceptions.cs
├── InstanceBuilders.cs
├── LinqToQuerystring.IntegrationTests.Mongo.csproj
├── MongoCollectionAggregates.cs
├── MongoDocument.cs
├── MongoDocumentClassSerializer.cs
├── MongoFiltering.cs
├── MongoFunctions.cs
├── MongoInlineCount.cs
├── MongoPagingAndOrdering.cs
├── MongoProjection.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── LinqToQuerystring.IntegrationTests.WebAPI
├── ContentNegotiationTests.cs
├── Controllers
│ ├── DataClass.cs
│ ├── DataController.cs
│ └── NonGenericController.cs
├── CsvMediaTypeFormatter.cs
├── LinqToQuerystring.IntegrationTests.WebApi.csproj
├── LinqToQuerystring.IntegrationTests.WebApi2.csproj
├── Properties
│ └── AssemblyInfo.cs
├── QuerySyntaxTests.cs
├── SimpleTracer.cs
└── packages.config
├── LinqToQuerystring.Javascript
├── LinqToQuerystring.g
├── antlr3-all-min.js
├── antlr3-all.js
├── antlr3-cli-min.js
├── antlr3-cli.js
├── demo.html
└── output
│ ├── LinqToQuerystring.tokens
│ ├── LinqToQuerystringLexer.js
│ └── LinqToQuerystringParser.js
├── LinqToQuerystring.Nancy
├── LinqToQuerystring.Nancy.csproj
├── LinqToQuerystring.Nancy.nuspec
├── NancyExtensions.cs
└── Properties
│ └── AssemblyInfo.cs
├── LinqToQuerystring.WebApi.sln
├── LinqToQuerystring.WebApi
├── LinqToQueryableAttribute.cs
├── LinqToQuerystring.WebAPI.nuspec
├── LinqToQuerystring.WebAPI2.nuspec
├── LinqToQuerystring.WebApi.csproj
├── LinqToQuerystring.WebApi2.csproj
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── LinqToQuerystring.WebApi2.sln
├── LinqToQuerystring.sln
├── LinqToQuerystring
├── Configuration.cs
├── Exceptions
│ ├── FunctionNotSupportedException.cs
│ └── InvalidEscapeSequenceException.cs
├── Extensions.cs
├── LinqToQuerystring.csproj
├── LinqToQuerystring.g
├── LinqToQuerystring.nuspec
├── LinqToQuerystring.tokens
├── LinqToQuerystringLexer.cs
├── LinqToQuerystringParser.cs
├── Properties
│ └── AssemblyInfo.cs
├── Settings.StyleCop
├── TreeNodes
│ ├── Aggregates
│ │ ├── AllNode.cs
│ │ ├── AnyNode.cs
│ │ ├── AverageNode.cs
│ │ ├── CountNode.cs
│ │ ├── MaxNode.cs
│ │ ├── MinNode.cs
│ │ └── SumNode.cs
│ ├── AliasNode.cs
│ ├── AndNode.cs
│ ├── AscNode.cs
│ ├── Base
│ │ ├── ExplicitOrderByBase.cs
│ │ ├── QueryModifier.cs
│ │ ├── SingleChildNode.cs
│ │ ├── TreeNode.cs
│ │ └── TwoChildNode.cs
│ ├── Comparisons
│ │ ├── EqualsNode.cs
│ │ ├── GreaterThanNode.cs
│ │ ├── GreaterThanOrEqualNode.cs
│ │ ├── LessThanNode.cs
│ │ ├── LessThanOrEqualNode.cs
│ │ └── NotEqualsNode.cs
│ ├── DataTypes
│ │ ├── BoolNode.cs
│ │ ├── ByteNode.cs
│ │ ├── DateTimeNode.cs
│ │ ├── DecimalNode.cs
│ │ ├── DoubleNode.cs
│ │ ├── GuidNode.cs
│ │ ├── IntNode.cs
│ │ ├── LongNode.cs
│ │ ├── SingleNode.cs
│ │ └── StringNode.cs
│ ├── DescNode.cs
│ ├── DynamicIdentifierNode.cs
│ ├── ExpandNode.cs
│ ├── FilterNode.cs
│ ├── Functions
│ │ ├── DayNode.cs
│ │ ├── DaysNode.cs
│ │ ├── EndsWithNode.cs
│ │ ├── HourNode.cs
│ │ ├── HoursNode.cs
│ │ ├── MinuteNode.cs
│ │ ├── MinutesNode.cs
│ │ ├── MonthNode.cs
│ │ ├── SecondNode.cs
│ │ ├── SecondsNode.cs
│ │ ├── StartsWithNode.cs
│ │ ├── SubstringOfNode.cs
│ │ ├── ToLowerNode.cs
│ │ ├── ToUpperNode.cs
│ │ ├── YearNode.cs
│ │ └── YearsNode.cs
│ ├── IdentifierNode.cs
│ ├── IgnoredNode.cs
│ ├── InlineCountNode.cs
│ ├── NotNode.cs
│ ├── NullNode.cs
│ ├── OrNode.cs
│ ├── OrderByNode.cs
│ ├── SelectNode.cs
│ ├── SkipNode.cs
│ ├── TopNode.cs
│ └── TreeNodeFactory.cs
├── Utils
│ └── CustomNodeMappings.cs
└── packages.config
├── README.md
└── lib
├── ANTLR
├── Antlr3.Runtime.Debug.dll
├── Antlr3.Runtime.dll
├── Antlr3.exe
├── Antlr3.exe.config
├── Antlr3.targets
├── Antlr4.StringTemplate.Visualizer.dll
├── Antlr4.StringTemplate.dll
├── AntlrBuildTask.dll
├── Codegen
│ └── Templates
│ │ ├── CSharp3
│ │ ├── AST.stg
│ │ ├── ASTDbg.stg
│ │ ├── ASTParser.stg
│ │ ├── ASTTreeParser.stg
│ │ ├── CSharp3.stg
│ │ ├── Dbg.stg
│ │ └── ST.stg
│ │ ├── JavaScript
│ │ ├── AST.stg
│ │ ├── ASTParser.stg
│ │ ├── ASTTreeParser.stg
│ │ └── JavaScript.stg
│ │ └── LeftRecursiveRules.stg
├── LICENSE.txt
├── Targets
│ ├── Antlr3.Targets.CSharp3.dll
│ └── Antlr3.Targets.JavaScript.dll
└── Tool
│ └── Templates
│ ├── depend.stg
│ ├── dot
│ └── dot.stg
│ └── messages
│ ├── formats
│ ├── antlr.stg
│ ├── gnu.stg
│ └── vs2005.stg
│ └── languages
│ └── en.stg
├── MongoDB.Bson.dll
├── MongoDB.Bson.xml
├── MongoDB.Driver.XML
└── MongoDB.Driver.dll
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | #################
33 | ## Visual Studio
34 | #################
35 |
36 | ## Ignore Visual Studio temporary files, build results, and
37 | ## files generated by popular Visual Studio add-ons.
38 |
39 | # User-specific files
40 | *.suo
41 | *.user
42 | *.sln.docstates
43 |
44 | # Build results
45 | [Dd]ebug/
46 | [Rr]elease/
47 | *_i.c
48 | *_p.c
49 | *.ilk
50 | *.meta
51 | *.obj
52 | *.pch
53 | *.pdb
54 | *.pgc
55 | *.pgd
56 | *.rsp
57 | *.sbr
58 | *.tlb
59 | *.tli
60 | *.tlh
61 | *.tmp
62 | *.vspscc
63 | .builds
64 | *.dotCover
65 | *.ncrunchsolution
66 | *.ncrunchproject
67 |
68 | ## TODO: If you have NuGet Package Restore enabled, uncomment this
69 | packages/
70 | _NCrunch_*/
71 |
72 | # Visual C++ cache files
73 | ipch/
74 | *.aps
75 | *.ncb
76 | *.opensdf
77 | *.sdf
78 |
79 | # Visual Studio profiler
80 | *.psess
81 | *.vsp
82 |
83 | # ReSharper is a .NET coding add-in
84 | _ReSharper*
85 |
86 | # Installshield output folder
87 | [Ee]xpress
88 |
89 | # DocProject is a documentation generator add-in
90 | DocProject/buildhelp/
91 | DocProject/Help/*.HxT
92 | DocProject/Help/*.HxC
93 | DocProject/Help/*.hhc
94 | DocProject/Help/*.hhk
95 | DocProject/Help/*.hhp
96 | DocProject/Help/Html2
97 | DocProject/Help/html
98 |
99 | # Click-Once directory
100 | publish
101 |
102 | # Others
103 | [Bb]in
104 | [Oo]bj
105 | sql
106 | TestResults
107 | *.Cache
108 | ClientBin
109 | stylecop.*
110 | ~$*
111 | *.dbmdl
112 | Generated_Code #added for RIA/Silverlight projects
113 |
114 | # Backup & report files from converting an old project file to a newer
115 | # Visual Studio version. Backup files are not needed, because we have git ;-)
116 | _UpgradeReport_Files/
117 | Backup*/
118 | UpgradeLog*.XML
119 |
120 |
121 |
122 | ############
123 | ## Windows
124 | ############
125 |
126 | # Windows image file caches
127 | Thumbs.db
128 |
129 | # Folder config file
130 | Desktop.ini
131 |
132 |
133 | #############
134 | ## Python
135 | #############
136 |
137 | *.py[co]
138 |
139 | # Packages
140 | *.egg
141 | *.egg-info
142 | dist
143 | build
144 | eggs
145 | parts
146 | bin
147 | var
148 | sdist
149 | develop-eggs
150 | .installed.cfg
151 |
152 | # Installer logs
153 | pip-log.txt
154 |
155 | # Unit test / coverage reports
156 | .coverage
157 | .tox
158 |
159 | #Translations
160 | *.mo
161 |
162 | #Mr Developer
163 | .mr.developer.cfg
164 |
165 | # Mac crap
166 | .DS_Store
167 | NuGetPackage/
168 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Peter Smith
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of
4 | this software and associated documentation files (the "Software"), to deal in
5 | the Software without restriction, including without limitation the rights to
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7 | the Software, and to permit persons to whom the Software is furnished to do so,
8 | subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/LinqToQueryString.IntegrationTests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/LinqToQueryString.IntegrationTests/Exceptions.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQueryString.IntegrationTests.Sql
2 | {
3 | using System;
4 | using System.Data;
5 | using System.Linq;
6 |
7 | using LinqToQuerystring;
8 |
9 | using Machine.Specifications;
10 |
11 | public class When_using_skip_on_unordered_data : SqlPagingAndOrdering
12 | {
13 | private static Exception ex;
14 |
15 | private Because of = () => ex = Catch.Exception(() => result = testDb.ConcreteCollection.LinqToQuerystring("?$skip=1").ToList());
16 |
17 | private It should_throw_an_exception = () => ex.ShouldBeOfType();
18 | }
19 |
20 | public class When_trying_to_order_by_complex_types : SqlPagingAndOrdering
21 | {
22 | private static Exception ex;
23 |
24 | private Because of = () => ex = Catch.Exception(() => complexResult = testDb.ComplexCollection.LinqToQuerystring("?$orderby=concrete").ToList());
25 |
26 | private It should_throw_an_exception = () => ex.ShouldBeOfType();
27 | }
28 |
29 | public class When_filtering_on_endswith_function : SqlFunctions
30 | {
31 | private static Exception ex;
32 |
33 | private Because of = () => ex = Catch.Exception(() => testDb.ConcreteCollection.LinqToQuerystring("?$filter=endswith(Name,'day')").ToList());
34 |
35 | private It should_throw_an_exception = () => ex.ShouldBeOfType();
36 |
37 | private It should_fail_due_to_SQL_CE_not_supporting_endswith =
38 | () =>
39 | ex.InnerException.Message.ShouldEqual("The function 'Reverse' is not supported by SQL Server Compact.");
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/LinqToQueryString.IntegrationTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LinqToQueryString.IntegrationTests.Sql")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LinqToQueryString")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("d3add83d-6f36-402d-8ac7-7fb1beda13dd")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/LinqToQueryString.IntegrationTests/TestDbContext.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQueryString.IntegrationTests.Sql
2 | {
3 | using System.Data.Entity;
4 |
5 | using LinqToQueryString.Tests;
6 |
7 | public class TestDbContext : DbContext
8 | {
9 | public DbSet ConcreteCollection { get; set; }
10 |
11 | public DbSet ComplexCollection { get; set; }
12 |
13 | public DbSet EdgeCaseCollection { get; set; }
14 |
15 | public DbSet NullableCollection { get; set; }
16 |
17 | public DbSet NullableContainers { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/LinqToQueryString.IntegrationTests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/LinqToQueryString.Tests/ComplexClass.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQueryString.Tests
2 | {
3 | using System.Collections.Generic;
4 |
5 | public class ComplexClass
6 | {
7 | public int Id { get; set; }
8 |
9 | public ConcreteClass Concrete { get; set; }
10 |
11 | public List StringCollection { get; set; }
12 |
13 | public List ConcreteCollection { get; set; }
14 |
15 | public string Title { get; set; }
16 |
17 | public List IntCollection { get; set; }
18 | }
19 |
20 | public class ComplexClassDto
21 | {
22 | public int Id { get; set; }
23 |
24 | public ConcreteClass Concrete { get; set; }
25 |
26 | public IEnumerable StringCollection { get; set; }
27 |
28 | public List ConcreteCollection { get; set; }
29 |
30 | public string Title { get; set; }
31 |
32 | public IEnumerable IntCollection { get; set; }
33 | }
34 |
35 | public class NullableClassDto
36 | {
37 | public IEnumerable NullableCollection { get; set; }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/LinqToQueryString.Tests/ConcreteClass.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQueryString.Tests
2 | {
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | public class ConcreteClass : IComparable
7 | {
8 | public ConcreteClass()
9 | {
10 | Date = DateTime.UtcNow;
11 | }
12 |
13 | public int Id { get; set; }
14 |
15 | public string Name { get; set; }
16 |
17 | public DateTime Date { get; set; }
18 |
19 | public bool Complete { get; set; }
20 |
21 | public int Age { get; set; }
22 |
23 | public List Children { get; set; }
24 |
25 | public IEnumerable StringCollection { get; set; }
26 |
27 | public long Population { get; set; }
28 |
29 | public double Value { get; set; }
30 |
31 | public float Cost { get; set; }
32 |
33 | public byte Code { get; set; }
34 |
35 | public Guid Guid { get; set; }
36 |
37 | public decimal Score { get; set; }
38 |
39 | public int CompareTo(ConcreteClass other)
40 | {
41 | return String.CompareOrdinal(this.Name, other.Name);
42 | }
43 | }
44 |
45 | public class EdgeCaseClass : IComparable
46 | {
47 | public EdgeCaseClass()
48 | {
49 | Date = DateTime.UtcNow;
50 | }
51 |
52 | public int Id { get; set; }
53 |
54 | public string Name { get; set; }
55 |
56 | public DateTime Date { get; set; }
57 |
58 | public bool Complete { get; set; }
59 |
60 | public int Age { get; set; }
61 |
62 | public int CompareTo(EdgeCaseClass other)
63 | {
64 | return String.CompareOrdinal(this.Name, other.Name);
65 | }
66 | }
67 |
68 | public class NullableContainer
69 | {
70 | public int Id { get; set; }
71 |
72 | public string Name { get; set; }
73 |
74 | public List Nullables { get; set; }
75 | }
76 |
77 | public class NullableValue
78 | {
79 | public int Id { get; set; }
80 |
81 | public int? Age { get; set; }
82 | }
83 |
84 | public class NullableClass
85 | {
86 | public int? Id { get; set; }
87 |
88 | public DateTime? Date { get; set; }
89 |
90 | public int? Age { get; set; }
91 |
92 | public bool? Complete { get; set; }
93 |
94 | public long? Population { get; set; }
95 |
96 | public double? Value { get; set; }
97 |
98 | public float? Cost { get; set; }
99 |
100 | public byte? Code { get; set; }
101 |
102 | public Guid? Guid { get; set; }
103 |
104 | public List NullableInts { get; set; }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/LinqToQueryString.Tests/IndexedClass.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQueryString.Tests
2 | {
3 | using System.Collections.Generic;
4 |
5 | public class IndexedClass
6 | {
7 | private readonly Dictionary dictionary;
8 |
9 | public IndexedClass(Dictionary dictionary)
10 | {
11 | this.dictionary = dictionary;
12 | }
13 |
14 | public object this[string index]
15 | {
16 | get
17 | {
18 | return this.dictionary[index];
19 | }
20 | set
21 | {
22 | this.dictionary[index] = value;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/LinqToQueryString.Tests/InstanceBuilders.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQueryString.Tests
2 | {
3 | using System;
4 |
5 | public static class InstanceBuilders
6 | {
7 | public static ConcreteClass BuildConcrete(string name, int age, DateTime date, bool complete)
8 | {
9 | return new ConcreteClass { Name = name, Date = date, Age = age, Complete = complete };
10 | }
11 |
12 | public static EdgeCaseClass BuildEdgeCase(string name, int age, DateTime date, bool complete)
13 | {
14 | return new EdgeCaseClass { Name = name, Date = date, Age = age, Complete = complete };
15 | }
16 |
17 | public static ConcreteClass BuildConcrete(string name, int age, DateTime date, bool complete, long population, double value, float cost, byte code, decimal score, Guid guid)
18 | {
19 | return new ConcreteClass { Name = name, Date = date, Age = age, Complete = complete, Population = population, Value = value, Cost = cost, Code = code, Score = score, Guid = guid };
20 | }
21 |
22 | public static NullableClass BuildNull()
23 | {
24 | return new NullableClass();
25 | }
26 |
27 | public static NullableClass BuildNull(int? age, DateTime? date, bool? complete, long? population, double? value, float? cost, byte? code, Guid? guid)
28 | {
29 | return new NullableClass { Date = date, Age = age, Complete = complete, Population = population, Value = value, Cost = cost, Code = code, Guid = guid };
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/LinqToQueryString.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LinqToQueryString.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LinqToQueryString.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("099dce67-e299-4269-94a8-56cc7194af8e")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/LinqToQueryString.Tests/RandomDataGenerators.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQueryString.Tests
2 | {
3 | using System;
4 |
5 | public static class RandomDataGenerators
6 | {
7 | private static readonly Random Random = new Random();
8 |
9 | public static string String()
10 | {
11 | return Guid.NewGuid().ToString();
12 | }
13 |
14 | public static int Int(int min, int max)
15 | {
16 | return Random.Next(min, max);
17 | }
18 |
19 | public static long Long()
20 | {
21 | return Random.Next(10000, 999999);
22 | }
23 |
24 | public static long Long(int min, int max)
25 | {
26 | return Random.Next(min, max);
27 | }
28 |
29 | public static Guid NewGuid()
30 | {
31 | return Guid.NewGuid();
32 | }
33 |
34 | public static DateTime DateAndTime()
35 | {
36 | var start = new DateTime(1995, 1, 1);
37 | var range = (int)(DateTime.Today - start).TotalDays;
38 | return start.AddDays(Random.Next(range));
39 | }
40 |
41 | public static bool Bool()
42 | {
43 | return Random.Next(0, 1) > 0;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/LinqToQueryString.UnitTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LinqToQueryString.UnitTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LinqToQueryString.UnitTests")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("7a619991-aea1-4715-987d-e76198f0d699")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/LinqToQueryString.UnitTests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo.Nancy/Bootstrapper.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.Demo.Nancy
2 | {
3 | using global::Nancy;
4 | using global::Nancy.Bootstrapper;
5 | using global::Nancy.Diagnostics;
6 | using global::Nancy.TinyIoc;
7 |
8 | public class Bootstrapper : DefaultNancyBootstrapper
9 | {
10 | protected override DiagnosticsConfiguration DiagnosticsConfiguration
11 | {
12 | get { return new DiagnosticsConfiguration { Password = @"password" }; }
13 | }
14 |
15 | protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
16 | {
17 | StaticConfiguration.EnableRequestTracing = true;
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo.Nancy/Models/Movie.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.Demo.Models
2 | {
3 | using System;
4 |
5 | public class Movie
6 | {
7 | public string Title { get; set; }
8 |
9 | public int DurationInMinutes { get; set; }
10 |
11 | public DateTime ReleaseDate { get; set; }
12 |
13 | public string Director { get; set; }
14 |
15 | public int MetaScore { get; set; }
16 |
17 | public bool Recommended { get; set; }
18 | }
19 | }
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo.Nancy/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LinqToQuerystring.Demo.Nancy")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LinqToQuerystring.Demo.Nancy")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("92a4fb3b-8056-4b3a-9970-7718f301757c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo.Nancy/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo.Nancy/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo.Nancy/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo.Nancy/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/App_Start/BundleConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Web;
2 | using System.Web.Optimization;
3 |
4 | namespace LinqToQuerystring.Demo
5 | {
6 | public class BundleConfig
7 | {
8 | // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
9 | public static void RegisterBundles(BundleCollection bundles)
10 | {
11 | bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
12 | "~/Scripts/jquery-{version}.js"));
13 |
14 | bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
15 | "~/Scripts/jquery-ui-{version}.js"));
16 |
17 | bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
18 | "~/Scripts/jquery.unobtrusive*",
19 | "~/Scripts/jquery.validate*"));
20 |
21 | bundles.Add(new ScriptBundle("~/bundles/knockout").Include(
22 | "~/Scripts/knockout-{version}.js"));
23 |
24 | bundles.Add(new ScriptBundle("~/bundles/odata").Include(
25 | "~/Scripts/jquery.ODataFilterUI*"));
26 |
27 | // Use the development version of Modernizr to develop with and learn from. Then, when you're
28 | // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
29 | bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
30 | "~/Scripts/modernizr-*"));
31 |
32 | bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
33 |
34 | bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
35 | "~/Content/themes/base/jquery.ui.core.css",
36 | "~/Content/themes/base/jquery.ui.resizable.css",
37 | "~/Content/themes/base/jquery.ui.selectable.css",
38 | "~/Content/themes/base/jquery.ui.accordion.css",
39 | "~/Content/themes/base/jquery.ui.autocomplete.css",
40 | "~/Content/themes/base/jquery.ui.button.css",
41 | "~/Content/themes/base/jquery.ui.dialog.css",
42 | "~/Content/themes/base/jquery.ui.slider.css",
43 | "~/Content/themes/base/jquery.ui.tabs.css",
44 | "~/Content/themes/base/jquery.ui.datepicker.css",
45 | "~/Content/themes/base/jquery.ui.progressbar.css",
46 | "~/Content/themes/base/jquery.ui.theme.css"));
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/App_Start/FilterConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Mvc;
2 |
3 | namespace LinqToQuerystring.Demo
4 | {
5 | public class FilterConfig
6 | {
7 | public static void RegisterGlobalFilters(GlobalFilterCollection filters)
8 | {
9 |
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/App_Start/RouteConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Mvc;
6 | using System.Web.Routing;
7 |
8 | namespace LinqToQuerystring.Demo
9 | {
10 | public class RouteConfig
11 | {
12 | public static void RegisterRoutes(RouteCollection routes)
13 | {
14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
15 |
16 | routes.MapRoute(
17 | name: "Default",
18 | url: "{controller}/{action}/{id}",
19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
20 | );
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/App_Start/WebApiConfig.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.Demo
2 | {
3 | using System.Web.Http;
4 |
5 | public static class WebApiConfig
6 | {
7 | public static void Register(HttpConfiguration config)
8 | {
9 | config.Routes.MapHttpRoute(
10 | name: "DefaultApi",
11 | routeTemplate: "api/{controller}/{id}",
12 | defaults: new { id = RouteParameter.Optional }
13 | );
14 |
15 | // Uncomment the following line of code to enable query support for actions with an IQueryable or IQueryable return type.
16 | // To avoid processing unexpected or malicious queries, use the validation settings on QueryableAttribute to validate incoming queries.
17 | // For more information, visit http://go.microsoft.com/fwlink/?LinkId=279712.
18 | //config.EnableQuerySupport();
19 |
20 | // To disable tracing in your application, please comment out or remove the following line of code
21 | // For more information, refer to: http://www.asp.net/web-api
22 | config.EnableSystemDiagnosticsTracing();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Controllers/HomeController.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.Demo.Controllers
2 | {
3 | using System.Web.Mvc;
4 |
5 | public class HomeController : Controller
6 | {
7 | public ActionResult Index()
8 | {
9 | return View();
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Filters/ApiExceptionFilterAttribute.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.Demo.Filters
2 | {
3 | using System;
4 | using System.Net;
5 | using System.Net.Http;
6 | using System.Web.Http.Filters;
7 |
8 | public class ApiExceptionFilterAttribute : ExceptionFilterAttribute
9 | {
10 | public override void OnException(HttpActionExecutedContext actionExecutedContext)
11 | {
12 | var argumentException = actionExecutedContext.Exception as Exception;
13 | if (argumentException != null)
14 | {
15 | var message = string.IsNullOrEmpty(argumentException.Message)
16 | ? "An exception occurred"
17 | : argumentException.Message;
18 |
19 | actionExecutedContext.Response = actionExecutedContext.Request.CreateErrorResponse(HttpStatusCode.BadRequest, message);
20 | actionExecutedContext.Response.Content.Headers.ContentType =
21 | actionExecutedContext.Request.Content.Headers.ContentType;
22 | }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Global.asax:
--------------------------------------------------------------------------------
1 | <%@ Application Codebehind="Global.asax.cs" Inherits="LinqToQuerystring.Demo.WebApiApplication" Language="C#" %>
2 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Global.asax.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Http;
6 | using System.Web.Mvc;
7 | using System.Web.Optimization;
8 | using System.Web.Routing;
9 |
10 | namespace LinqToQuerystring.Demo
11 | {
12 | // Note: For instructions on enabling IIS6 or IIS7 classic mode,
13 | // visit http://go.microsoft.com/?LinkId=9394801
14 |
15 | public class WebApiApplication : System.Web.HttpApplication
16 | {
17 | protected void Application_Start()
18 | {
19 | AreaRegistration.RegisterAllAreas();
20 |
21 | WebApiConfig.Register(GlobalConfiguration.Configuration);
22 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
23 | RouteConfig.RegisterRoutes(RouteTable.Routes);
24 | BundleConfig.RegisterBundles(BundleTable.Bundles);
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Images/accent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/Images/accent.png
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Images/bullet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/Images/bullet.png
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Images/heroAccent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/Images/heroAccent.png
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Images/orderedList0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/Images/orderedList0.png
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Images/orderedList1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/Images/orderedList1.png
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Images/orderedList2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/Images/orderedList2.png
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Images/orderedList3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/Images/orderedList3.png
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Images/orderedList4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/Images/orderedList4.png
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Images/orderedList5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/Images/orderedList5.png
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Images/orderedList6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/Images/orderedList6.png
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Images/orderedList7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/Images/orderedList7.png
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Images/orderedList8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/Images/orderedList8.png
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Images/orderedList9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/Images/orderedList9.png
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Models/Movie.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.Demo.Models
2 | {
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | public class Movie
7 | {
8 | public string Title { get; set; }
9 |
10 | public int DurationInMinutes { get; set; }
11 |
12 | public DateTime ReleaseDate { get; set; }
13 |
14 | public string Director { get; set; }
15 |
16 | public int MetaScore { get; set; }
17 |
18 | public bool Recommended { get; set; }
19 |
20 | public List Tags { get; set; }
21 |
22 | public List UserScores { get; set; }
23 | }
24 | }
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LinqToQuerystring.Demo")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LinqToQuerystring.Demo")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("71dcf2b6-920d-4683-b6f1-e92d7e851442")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Properties/PublishProfiles/linqtoquerystring - FTP.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | FTP
9 | Release
10 | Any CPU
11 | http://linqtoquerystring.azurewebsites.net
12 | False
13 | ftp://waws-prod-am2-001.ftp.azurewebsites.windows.net
14 | False
15 | True
16 | site/wwwroot
17 | linqtoquerystring\$linqtoquerystring
18 | <_SavePWD>True
19 |
20 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Properties/PublishProfiles/linqtoquerystring - Web Deploy.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | MSDeploy
9 | Release
10 | Any CPU
11 | http://linqtoquerystring.azurewebsites.net
12 | False
13 | waws-prod-am2-001.publish.azurewebsites.windows.net:443
14 | linqtoquerystring
15 |
16 | True
17 | WMSVC
18 | True
19 | $linqtoquerystring
20 | <_SavePWD>True
21 |
22 |
23 |
24 |
25 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | False
39 |
40 |
41 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Scripts/_references.js:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 | ///
5 | ///
6 | ///
7 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Scripts/jquery.unobtrusive-ajax.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | ** Unobtrusive Ajax support library for jQuery
3 | ** Copyright (C) Microsoft Corporation. All rights reserved.
4 | */
5 | (function(a){var b="unobtrusiveAjaxClick",g="unobtrusiveValidation";function c(d,b){var a=window,c=(d||"").split(".");while(a&&c.length)a=a[c.shift()];if(typeof a==="function")return a;b.push(d);return Function.constructor.apply(null,b)}function d(a){return a==="GET"||a==="POST"}function f(b,a){!d(a)&&b.setRequestHeader("X-HTTP-Method-Override",a)}function h(c,b,e){var d;if(e.indexOf("application/x-javascript")!==-1)return;d=(c.getAttribute("data-ajax-mode")||"").toUpperCase();a(c.getAttribute("data-ajax-update")).each(function(f,c){var e;switch(d){case"BEFORE":e=c.firstChild;a("").html(b).contents().each(function(){c.insertBefore(this,e)});break;case"AFTER":a("").html(b).contents().each(function(){c.appendChild(this)});break;default:a(c).html(b)}})}function e(b,e){var j,k,g,i;j=b.getAttribute("data-ajax-confirm");if(j&&!window.confirm(j))return;k=a(b.getAttribute("data-ajax-loading"));i=b.getAttribute("data-ajax-loading-duration")||0;a.extend(e,{type:b.getAttribute("data-ajax-method")||undefined,url:b.getAttribute("data-ajax-url")||undefined,beforeSend:function(d){var a;f(d,g);a=c(b.getAttribute("data-ajax-begin"),["xhr"]).apply(this,arguments);a!==false&&k.show(i);return a},complete:function(){k.hide(i);c(b.getAttribute("data-ajax-complete"),["xhr","status"]).apply(this,arguments)},success:function(a,e,d){h(b,a,d.getResponseHeader("Content-Type")||"text/html");c(b.getAttribute("data-ajax-success"),["data","status","xhr"]).apply(this,arguments)},error:c(b.getAttribute("data-ajax-failure"),["xhr","status","error"])});e.data.push({name:"X-Requested-With",value:"XMLHttpRequest"});g=e.type.toUpperCase();if(!d(g)){e.type="POST";e.data.push({name:"X-HTTP-Method-Override",value:g})}a.ajax(e)}function i(c){var b=a(c).data(g);return!b||!b.validate||b.validate()}a(document).on("click","a[data-ajax=true]",function(a){a.preventDefault();e(this,{url:this.href,type:"GET",data:[]})});a(document).on("click","form[data-ajax=true] input[type=image]",function(c){var g=c.target.name,d=a(c.target),f=d.parents("form")[0],e=d.offset();a(f).data(b,[{name:g+".x",value:Math.round(c.pageX-e.left)},{name:g+".y",value:Math.round(c.pageY-e.top)}]);setTimeout(function(){a(f).removeData(b)},0)});a(document).on("click","form[data-ajax=true] :submit",function(c){var e=c.target.name,d=a(c.target).parents("form")[0];a(d).data(b,e?[{name:e,value:c.target.value}]:[]);setTimeout(function(){a(d).removeData(b)},0)});a(document).on("submit","form[data-ajax=true]",function(d){var c=a(this).data(b)||[];d.preventDefault();if(!i(this))return;e(this,{url:this.action,type:this.method||"GET",data:c.concat(a(this).serializeArray())})})})(jQuery);
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Views/Shared/Error.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | Layout = null;
3 | }
4 |
5 |
6 |
7 |
8 |
9 | Error
10 |
11 |
12 |
13 | Error.
14 | An error occurred while processing your request.
15 |
16 |
17 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Views/Shared/_Layout.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | @ViewBag.Title
7 | @Styles.Render("~/Content/css")
8 | @Scripts.Render("~/bundles/modernizr")
9 |
10 |
11 |
12 |
13 |
17 |
18 |
23 |
24 |
25 |
26 | @RenderBody()
27 |
28 | @Scripts.Render("~/bundles/jquery")
29 | @Scripts.Render("~/bundles/knockout")
30 | @Scripts.Render("~/bundles/odata")
31 | @RenderSection("scripts", required: false)
32 |
33 |
34 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Views/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
40 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Views/_ViewStart.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | Layout = "~/Views/Shared/_Layout.cshtml";
3 | }
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beyond-code-github/LinqToQuerystring/f10c41a86eced0f2cee830f07e8fc71e35496345/LinqToQuerystring.Demo/favicon.ico
--------------------------------------------------------------------------------
/LinqToQuerystring.Demo/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/LinqToQuerystring.EntityFramework/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/LinqToQuerystring.EntityFramework/Configuration.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.EntityFramework
2 | {
3 | using LinqToQuerystring.Utils;
4 |
5 | public static class Configuration
6 | {
7 | public static void Init()
8 | {
9 | if (!LinqToQuerystring.Configuration.CustomNodes.ContainsKey("DbQueryProvider"))
10 | {
11 | LinqToQuerystring.Configuration.CustomNodes.Add("DbQueryProvider", new CustomNodeMappings());
12 | }
13 |
14 | var objectQueryNodes = LinqToQuerystring.Configuration.CustomNodes["DbQueryProvider"];
15 | if (!objectQueryNodes.ContainsKey(LinqToQuerystringLexer.EXPAND))
16 | {
17 | objectQueryNodes.Add(
18 | LinqToQuerystringLexer.EXPAND, (type, token, factory) => new ExpandNode(type, token, factory));
19 | }
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/LinqToQuerystring.EntityFramework/ExpandNode.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.EntityFramework
2 | {
3 | using System;
4 | using System.Data.Entity;
5 | using System.Linq;
6 | using System.Linq.Expressions;
7 |
8 | using Antlr.Runtime;
9 |
10 | using LinqToQuerystring.TreeNodes;
11 | using LinqToQuerystring.TreeNodes.Base;
12 |
13 | public class ExpandNode : QueryModifier
14 | {
15 | public ExpandNode(Type inputType, IToken payload, TreeNodeFactory treeNodeFactory)
16 | : base(inputType, payload, treeNodeFactory)
17 | {
18 | }
19 |
20 | public override IQueryable ModifyQuery(IQueryable query)
21 | {
22 | foreach (var child in this.ChildNodes)
23 | {
24 | var parameter = Expression.Parameter(this.inputType, "o");
25 | var childExpression = child.BuildLinqExpression(query, query.Expression, parameter);
26 |
27 | var member = childExpression as MemberExpression;
28 | query = query.Include(member.Member.Name);
29 | }
30 |
31 | return query;
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/LinqToQuerystring.EntityFramework/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LinqToQuerystring.EntityFramework")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LinqToQuerystring.EntityFramework")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("8beb2ad7-d375-4cfc-bdf4-d7f9b0d6a1ee")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.1.1.0")]
36 | [assembly: AssemblyFileVersion("1.1.1.0")]
37 |
--------------------------------------------------------------------------------
/LinqToQuerystring.EntityFramework/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LinqToQuerystring.IntegrationTests.EntityFramework/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/LinqToQuerystring.IntegrationTests.EntityFramework/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LinqToQuerystring.IntegrationTests.EntityFramework")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LinqToQuerystring.IntegrationTests.EntityFramework")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("ef0c64e1-f0dc-420a-a8c2-f4621ac91ee2")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/LinqToQuerystring.IntegrationTests.EntityFramework/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LinqToQuerystring.IntegrationTests.Mongo/ConcreteMongoClass.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.IntegrationTests.Mongo
2 | {
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | using MongoDB.Bson;
7 | using MongoDB.Bson.Serialization.Attributes;
8 |
9 | public class ConcreteMongoClass
10 | {
11 | [BsonId]
12 | [BsonRepresentation(BsonType.String)]
13 | public string Id { get; set; }
14 |
15 | public string Name { get; set; }
16 |
17 | public DateTime Date { get; set; }
18 |
19 | public bool Complete { get; set; }
20 |
21 | public int Age { get; set; }
22 |
23 | public List StringCollection { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/LinqToQuerystring.IntegrationTests.Mongo/MongoDocument.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.IntegrationTests.Mongo
2 | {
3 | using System;
4 |
5 | using MongoDB.Bson;
6 | using MongoDB.Bson.Serialization;
7 | using MongoDB.Bson.Serialization.Attributes;
8 |
9 | [Serializable]
10 | [BsonSerializer(typeof(MongoDocumentClassSerializer))]
11 | public class MongoDocument : BsonDocumentBackedClass
12 | {
13 | public MongoDocument()
14 | : base(new MongoDocumentClassSerializer())
15 | {
16 | }
17 |
18 | public MongoDocument(BsonDocument backingDocument)
19 | : base(backingDocument, new MongoDocumentClassSerializer())
20 | {
21 | }
22 |
23 | public MongoDocument(BsonDocument backingDocument, IBsonDocumentSerializer serializer)
24 | : base(backingDocument, serializer)
25 | {
26 |
27 | }
28 |
29 | [BsonId]
30 | public ObjectId Id { get; set; }
31 |
32 | public BsonValue this[string fieldname]
33 | {
34 | get
35 | {
36 | return this.BackingDocument[fieldname];
37 | }
38 |
39 | set
40 | {
41 | this.BackingDocument[fieldname] = value;
42 | }
43 | }
44 |
45 | public static implicit operator BsonDocument(MongoDocument document)
46 | {
47 | return document.BackingDocument;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/LinqToQuerystring.IntegrationTests.Mongo/MongoDocumentClassSerializer.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.IntegrationTests.Mongo
2 | {
3 | using System;
4 |
5 | using MongoDB.Bson;
6 | using MongoDB.Bson.Serialization;
7 | using MongoDB.Bson.Serialization.IdGenerators;
8 | using MongoDB.Bson.Serialization.Serializers;
9 |
10 | public class MongoDocumentClassSerializer : BsonDocumentBackedClassSerializer, IBsonIdProvider
11 | {
12 | public MongoDocumentClassSerializer()
13 | {
14 | this.RegisterMember("Id", "_id", ObjectIdSerializer.Instance, typeof(ObjectId), null);
15 | }
16 |
17 | protected override MongoDocument CreateInstance(BsonDocument backingDocument)
18 | {
19 | return new MongoDocument(backingDocument, this);
20 | }
21 |
22 | public bool GetDocumentId(object document, out object id, out Type idNominalType, out IIdGenerator idGenerator)
23 | {
24 | idNominalType = typeof(ObjectId);
25 | idGenerator = ObjectIdGenerator.Instance;
26 |
27 | var mongoDocument = document as MongoDocument;
28 | if (mongoDocument == null)
29 | {
30 | id = null;
31 | return false;
32 | }
33 |
34 | id = mongoDocument.Id;
35 | return true;
36 | }
37 |
38 | public void SetDocumentId(object document, object id)
39 | {
40 | var mongoDocument = document as MongoDocument;
41 | if (mongoDocument != null)
42 | {
43 | mongoDocument.Id = (ObjectId)id;
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/LinqToQuerystring.IntegrationTests.Mongo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LinqToQuerystring.IntegrationTests.Mongo")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LinqToQuerystring.IntegrationTests.Mongo")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("dd21eed0-3fb8-4bf5-9486-67fcfba1df43")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/LinqToQuerystring.IntegrationTests.Mongo/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/LinqToQuerystring.IntegrationTests.WebAPI/ContentNegotiationTests.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.IntegrationTests.WebApi
2 | {
3 | using System.Linq;
4 | using System.Net;
5 | using System.Net.Http;
6 | using System.Web.Http;
7 | using System.Web.Http.Tracing;
8 |
9 | using Machine.Specifications;
10 |
11 | using WebAPI.Testing;
12 |
13 | public abstract class ContentNegotiationTestsBase
14 | {
15 | protected static Browser browser;
16 |
17 | protected static HttpResponseMessage response;
18 |
19 | protected Establish context = () =>
20 | {
21 | var config = new HttpConfiguration();
22 | config.Services.Replace(typeof(ITraceWriter), new SimpleTracer());
23 | config.Formatters.Add(new CsvMediaTypeFormatter());
24 |
25 | config.Routes.MapHttpRoute(
26 | name: "DefaultApi",
27 | routeTemplate: "api/{controller}/{id}",
28 | defaults: new { id = RouteParameter.Optional }
29 | );
30 |
31 | browser = new Browser(config);
32 | };
33 | }
34 |
35 | public class AcceptsJson : ContentNegotiationTestsBase
36 | {
37 | private Because of = () => response = browser.Get(
38 | "/api/data/",
39 | (with) =>
40 | {
41 | with.Header("Accept", "application/json");
42 | with.HttpRequest();
43 | });
44 |
45 | private It should_return_200_ok = () => response.StatusCode.ShouldEqual(HttpStatusCode.OK);
46 | }
47 |
48 | public class AcceptsXml : ContentNegotiationTestsBase
49 | {
50 | private Because of = () => response = browser.Get(
51 | "/api/data/",
52 | (with) =>
53 | {
54 | with.Header("Accept", "application/xml");
55 | with.HttpRequest();
56 | });
57 |
58 | private It should_return_200_ok = () => response.StatusCode.ShouldEqual(HttpStatusCode.OK);
59 |
60 | private It should_return_xml = () => response.Content.Headers.GetValues("Content-Type").FirstOrDefault().ShouldStartWith("application/xml");
61 | }
62 |
63 | public class Can_handle_media_type_mappings : ContentNegotiationTestsBase
64 | {
65 | private Because of = () => response = browser.Get(
66 | "/api/data?format=csv",
67 | (with) =>
68 | {
69 | with.Header("Accept", "text/csv");
70 | with.HttpRequest();
71 | });
72 |
73 | private It should_return_200_ok = () => response.StatusCode.ShouldEqual(HttpStatusCode.OK);
74 |
75 | private It should_return_xml = () => response.Content.Headers.GetValues("Content-Type").FirstOrDefault().ShouldStartWith("text/csv");
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/LinqToQuerystring.IntegrationTests.WebAPI/Controllers/DataClass.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.IntegrationTests.WebApi.Controllers
2 | {
3 | using System;
4 |
5 | [Serializable]
6 | public class DataClass
7 | {
8 | private readonly string name;
9 |
10 | private readonly int age;
11 |
12 | private readonly bool awesome;
13 |
14 | public string Name
15 | {
16 | get
17 | {
18 | return this.name;
19 | }
20 | }
21 |
22 | public int Age
23 | {
24 | get
25 | {
26 | return this.age;
27 | }
28 | }
29 |
30 | public bool Awesome
31 | {
32 | get
33 | {
34 | return this.awesome;
35 | }
36 | }
37 |
38 | public DataClass(string name, int age, bool awesome)
39 | {
40 | this.name = name;
41 | this.age = age;
42 | this.awesome = awesome;
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/LinqToQuerystring.IntegrationTests.WebAPI/Controllers/DataController.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.IntegrationTests.WebApi.Controllers
2 | {
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Web.Http;
6 |
7 | using LinqToQuerystring.WebApi;
8 |
9 | public class DataController : ApiController
10 | {
11 | [LinqToQueryable]
12 | public IQueryable Get()
13 | {
14 | return
15 | new List
16 | {
17 | new DataClass("Peter", 29, true),
18 | new DataClass("Kathryn", 26, false)
19 | }.AsQueryable();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/LinqToQuerystring.IntegrationTests.WebAPI/Controllers/NonGenericController.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.IntegrationTests.WebApi.Controllers
2 | {
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Web.Http;
6 |
7 | using LinqToQuerystring.WebApi;
8 |
9 | public class NonGenericController : ApiController
10 | {
11 | [LinqToQueryable]
12 | public IQueryable Get()
13 | {
14 | return
15 | new List
16 | {
17 | new DataClass("Peter", 29, true),
18 | new DataClass("Kathryn", 26, false)
19 | }.AsQueryable();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/LinqToQuerystring.IntegrationTests.WebAPI/CsvMediaTypeFormatter.cs:
--------------------------------------------------------------------------------
1 | namespace LinqToQuerystring.IntegrationTests.WebApi
2 | {
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Net.Http.Formatting;
8 | using System.Net.Http.Headers;
9 |
10 | public class CsvMediaTypeFormatter : BufferedMediaTypeFormatter
11 | {
12 | public CsvMediaTypeFormatter()
13 | {
14 | SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/csv"));
15 | MediaTypeMappings.Add(new QueryStringMapping("format", "csv", "text/csv"));
16 | }
17 |
18 | public override bool CanReadType(Type type)
19 | {
20 | return false;
21 | }
22 |
23 | public override bool CanWriteType(Type type)
24 | {
25 | return true;
26 | }
27 |
28 | public override void WriteToStream(
29 | Type type,
30 | object value,
31 | Stream writeStream,
32 | System.Net.Http.HttpContent content)
33 | {
34 | var itemType = type.GetGenericArguments()[0];
35 | var stringWriter = new StringWriter();
36 |
37 | stringWriter.WriteLine(string.Join(",", itemType.GetProperties().Select(x => x.Name)));
38 |
39 | foreach (var obj in (IEnumerable