Skip to content

Add empty list initalizers to help avoid NREs #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DataTables.Queryable/DataTables.Queryable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<Compile Include="DataTablesQueryProvider.cs" />
<Compile Include="DataTablesRequest.cs" />
<Compile Include="ExpressionExtensions.cs" />
<Compile Include="NoPropertyByNameException.cs" />
<Compile Include="PagedList.cs" />
<Compile Include="PredicateBuilder.cs" />
<Compile Include="QueryableExtensions.cs" />
Expand Down
6 changes: 6 additions & 0 deletions DataTables.Queryable/DataTablesAjaxPostModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ namespace DataTables.Queryable
/// </remarks>
public class DataTablesAjaxPostModel
{
public DataTablesAjaxPostModel()
{
Columns = new List<ColumnData>();
Order = new List<OrderData>();
}

/// <summary>
/// Draw counter. This is used by DataTables to ensure that the Ajax returns from
/// server-side processing requests are drawn in sequence by DataTables
Expand Down
6 changes: 3 additions & 3 deletions DataTables.Queryable/DataTablesRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

Expand All @@ -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<T>()
Expand Down
9 changes: 9 additions & 0 deletions DataTables.Queryable/NoPropertyByNameException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace DataTables.Queryable
{
public class NoPropertyByNameException : Exception
{
public NoPropertyByNameException(string message) : base(message) { }
}
}