diff --git a/DataTables.Queryable/DataTables.Queryable.csproj b/DataTables.Queryable/DataTables.Queryable.csproj index f47ca87..d349d44 100644 --- a/DataTables.Queryable/DataTables.Queryable.csproj +++ b/DataTables.Queryable/DataTables.Queryable.csproj @@ -41,6 +41,7 @@ + diff --git a/DataTables.Queryable/DataTablesAjaxPostModel.cs b/DataTables.Queryable/DataTablesAjaxPostModel.cs index 547cf5c..68ee82d 100644 --- a/DataTables.Queryable/DataTablesAjaxPostModel.cs +++ b/DataTables.Queryable/DataTablesAjaxPostModel.cs @@ -16,6 +16,12 @@ namespace DataTables.Queryable /// public class DataTablesAjaxPostModel { + public DataTablesAjaxPostModel() + { + Columns = new List(); + Order = new List(); + } + /// /// Draw counter. This is used by DataTables to ensure that the Ajax returns from /// server-side processing requests are drawn in sequence by DataTables diff --git a/DataTables.Queryable/DataTablesRequest.cs b/DataTables.Queryable/DataTablesRequest.cs index 205ff7c..9d306bd 100644 --- a/DataTables.Queryable/DataTablesRequest.cs +++ b/DataTables.Queryable/DataTablesRequest.cs @@ -180,7 +180,7 @@ public DataTablesRequest(NameValueCollection query) } else { - throw new ArgumentException($"Could not find a property called \"{data}\" on type \"{type}\". Make sure you have specified correct value of \"columnDefs.data\" parameter in datatables options."); + throw new NoPropertyByNameException($"Could not find a property called \"{data}\" on type \"{type}\". Make sure you have specified correct value of \"columnDefs.data\" parameter in datatables options."); } } @@ -194,13 +194,13 @@ public DataTablesRequest(NameValueCollection query) } else { - throw new ArgumentException($"Could not find a property called \"{name}\" on type \"{type}\". Make sure you have specified correct value of \"columnDefs.name\" parameter in datatables options."); + throw new NoPropertyByNameException($"Could not find a property called \"{name}\" on type \"{type}\". Make sure you have specified correct value of \"columnDefs.name\" parameter in datatables options."); } } if (propertyName == null) { - throw new ArgumentException($"Unable to associate datatables column \"{colIndex}\" with model type \"{typeof(T)}\". There are no matching public property found. Make sure you specified valid identifiers for \"columnDefs.data\" and/or \"columnDefs.name\" parameters in datatables options for the column \"{colIndex}\"."); + throw new NoPropertyByNameException($"Unable to associate datatables column \"{colIndex}\" with model type \"{typeof(T)}\". There are no matching public property found. Make sure you specified valid identifiers for \"columnDefs.data\" and/or \"columnDefs.name\" parameters in datatables options for the column \"{colIndex}\"."); } var column = new DataTablesColumn() diff --git a/DataTables.Queryable/NoPropertyByNameException.cs b/DataTables.Queryable/NoPropertyByNameException.cs new file mode 100644 index 0000000..ce40089 --- /dev/null +++ b/DataTables.Queryable/NoPropertyByNameException.cs @@ -0,0 +1,9 @@ +using System; + +namespace DataTables.Queryable +{ + public class NoPropertyByNameException : Exception + { + public NoPropertyByNameException(string message) : base(message) { } + } +}