Skip to content

Commit 50ee6e2

Browse files
Merge pull request #27 from garvincasimir/formatters
Adding syntax highlighting to readme
2 parents 6543785 + 53c33bd commit 50ee6e2

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Please see the [official datatables documentation](http://datatables.net/release
3737
The following snippets were taken from the aspnet-core-sample project also located in this repository
3838

3939
**HomeController.cs**
40-
40+
```c#
4141
public class HomeController : Controller
4242
{
4343
private readonly PersonContext _context;
@@ -58,9 +58,9 @@ The following snippets were taken from the aspnet-core-sample project also locat
5858
return Json(parser.Parse());
5959
}
6060
}
61-
61+
```
6262
**Startup.cs**
63-
63+
```c#
6464
public IServiceProvider ConfigureServices(IServiceCollection services)
6565
{
6666

@@ -74,9 +74,9 @@ The following snippets were taken from the aspnet-core-sample project also locat
7474

7575
return services.BuildServiceProvider();
7676
}
77-
77+
```
7878
**Index.cshtml**
79-
79+
```html
8080
@{
8181
ViewData["title"] = "People Table";
8282
}
@@ -113,7 +113,7 @@ The following snippets were taken from the aspnet-core-sample project also locat
113113

114114

115115
}
116-
116+
```
117117
The included Dockerfile-websample builds, packages and runs the web sample project in a docker image. No tools, frameworks or runtimes are required on the host machine. The image has been published to docker for your convenience.
118118

119119
docker run -p 80:80 garvincasimir/datatables-aspnet-core-sample:0.0.2
@@ -122,7 +122,7 @@ Custom Filter Expressions
122122
========================
123123
The parser builds a set of expressions based on the settings and filter text sent from Datatables. The end result is a *WHERE* clause which looks something like this:
124124

125-
```
125+
```sql
126126
FROM [People] AS [val]
127127
WHERE ((((CASE
128128
WHEN CHARINDEX(N'cromie', LOWER([val].[FirstName])) > 0
@@ -154,7 +154,7 @@ What is missing in the above expression is the ability to format dates to match
154154

155155
For example, if your provider does support *DateTime.ToString(string format)*, you can substitute .ToString() with that expression after initializing the parser. This must be explicitly called for each applicable property.
156156

157-
```
157+
```c#
158158
var parser = new Parser<Person>(p, context.People)
159159
.SetConverter(x => x.BirthDate, x => x.BirthDate.ToString("M/dd/yyyy"))
160160
.SetConverter(x => x.LastUpdated, x => x.LastUpdated.ToString("M/dd/yyyy"));
@@ -165,7 +165,7 @@ var parser = new Parser<Person>(p, context.People)
165165
In EF Core 2 you can map user defined and system scalar valued functions and use them for formatting. The following is an example for SQL Server >= 2012.
166166

167167
PersonContext.cs
168-
```
168+
```c#
169169
using Microsoft.EntityFrameworkCore;
170170
using System;
171171

@@ -193,15 +193,15 @@ PersonContext.cs
193193
```
194194
Parser initialization
195195

196-
```
196+
```c#
197197

198198
var parser = new Parser<Person>(p, context.People)
199199
.SetConverter(x => x.BirthDate, x => PersonContext.Format(x.BirthDate,"M/dd/yyyy"));
200200
```
201201

202202
The *WHERE* clause now looks like this:
203203

204-
```
204+
```sql
205205
WHERE ((((CASE
206206
WHEN CHARINDEX(N'9/03/1953', LOWER([val].[FirstName])) > 0
207207
THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT)

0 commit comments

Comments
 (0)