diff --git a/AspNetCoreWeb/AspNetCoreWeb.csproj b/AspNetCoreWeb/AspNetCoreWeb.csproj
index 6fabeee..7b26f25 100644
--- a/AspNetCoreWeb/AspNetCoreWeb.csproj
+++ b/AspNetCoreWeb/AspNetCoreWeb.csproj
@@ -35,7 +35,7 @@
-
+
diff --git a/AspNetCoreWeb/Extentions/DataTableExtentions.cs b/AspNetCoreWeb/Extentions/DataTableExtentions.cs
new file mode 100644
index 0000000..e015411
--- /dev/null
+++ b/AspNetCoreWeb/Extentions/DataTableExtentions.cs
@@ -0,0 +1,49 @@
+using JqueryDataTables.ServerSide.AspNetCoreWeb.Models;
+using Newtonsoft.Json;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace JqueryDataTables.ServerSide.AspNetCoreWeb.Extentions
+{
+ ///
+ /// Extention Methods to convert data table result from list
+ ///
+ public static class DataTableExtentions
+ {
+ public static JqueryDataTablesResult ToDataTable(this IEnumerable list, int draw, int totalCount, int filteredCount)
+ {
+ return new JqueryDataTablesResult
+ {
+ Data = list,
+ Draw = draw,
+ RecordsFiltered = filteredCount,
+ RecordsTotal = totalCount
+ };
+ }
+ public static JqueryDataTablesResult ToDataTable(this IEnumerable list, int draw, int totalCount)
+ {
+ return new JqueryDataTablesResult
+ {
+ Data = list,
+ Draw = draw,
+ RecordsFiltered = list.Count(),
+ RecordsTotal = totalCount
+ };
+ }
+ public static JqueryDataTablesResult ToDataTable(this IEnumerable list, int draw)
+ {
+ return new JqueryDataTablesResult
+ {
+ Data = list,
+ Draw = draw,
+ RecordsFiltered = list.Count(),
+ RecordsTotal = list.Count()
+ };
+ }
+ public static string ToJsonString(this JqueryDataTablesResult result)
+ {
+ var json = JsonConvert.SerializeObject(result);
+ return json;
+ }
+ }
+}
diff --git a/AspNetCoreWeb/Models/JqueryDataTablesModel.cs b/AspNetCoreWeb/Models/JqueryDataTablesModel.cs
index b22747a..149307d 100644
--- a/AspNetCoreWeb/Models/JqueryDataTablesModel.cs
+++ b/AspNetCoreWeb/Models/JqueryDataTablesModel.cs
@@ -16,22 +16,19 @@ public class JqueryDataTablesResult
/// The draw counter that this object is a response to - from the draw parameter sent as part of the data request.
/// Note that it is strongly recommended for security reasons that you cast this parameter to an integer, rather than simply echoing back to the client what it sent in the draw parameter, in order to prevent Cross Site Scripting (XSS) attacks.
///
- [JsonProperty(PropertyName = "draw")]
- [JsonPropertyName("draw")]
+ [JsonProperty("draw")]
public int Draw { get; set; }
///
/// Total records, before filtering (i.e. the total number of records in the database)
///
- [JsonProperty(PropertyName = "recordsTotal")]
- [JsonPropertyName("recordsTotal")]
+ [JsonProperty("recordsTotal")]
public int RecordsTotal { get; set; }
///
/// Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned for this page of data).
///
- [JsonProperty(PropertyName = "recordsFiltered")]
- [JsonPropertyName("recordsFiltered")]
+ [JsonProperty("recordsFiltered")]
public int RecordsFiltered { get; set; }
///
@@ -39,8 +36,7 @@ public class JqueryDataTablesResult
/// This is an array of data source objects, one for each row, which will be used by DataTables.
/// Note that this parameter's name can be changed using the ajaxDT option's dataSrc property.
///
- [JsonProperty(PropertyName = "data")]
- [JsonPropertyName("data")]
+ [JsonProperty("data")]
public IEnumerable Data { get; set; }
}
diff --git a/AspNetCoreWeb/Models/JqueryDataTablesPagedResults{T}.cs b/AspNetCoreWeb/Models/JqueryDataTablesPagedResults{T}.cs
index 9e09266..80b57df 100644
--- a/AspNetCoreWeb/Models/JqueryDataTablesPagedResults{T}.cs
+++ b/AspNetCoreWeb/Models/JqueryDataTablesPagedResults{T}.cs
@@ -2,7 +2,7 @@
namespace JqueryDataTables.ServerSide.AspNetCoreWeb.Models
{
- public class JqueryDataTablesPagedResults
+ public class JqueryDataTablesResults
{
public IEnumerable Items { get; set; }