-
Notifications
You must be signed in to change notification settings - Fork 20
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
base: master
Are you sure you want to change the base?
Conversation
We need a better way for defaults too.
This is when I try and POST to my controller with |
This is a start for defaults: public class DataTablesAjaxPostModelDefaultsActionFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext context)
{
var argumentTypes = context.ActionArguments;
var dataTablesAjaxPostModelArgument = context.ActionArguments
.SingleOrDefault(x => x.Value.GetType() == typeof(DataTablesAjaxPostModel));
if (dataTablesAjaxPostModelArgument.Value != null)
{
var dataTablesAjaxPostModel = (DataTablesAjaxPostModel)dataTablesAjaxPostModelArgument.Value;
if(dataTablesAjaxPostModel.Length == default)
{
dataTablesAjaxPostModel.Length = 50;
}
if (dataTablesAjaxPostModel.Order == null)
{
dataTablesAjaxPostModel.Order = new List<DataTablesAjaxPostModel.OrderData>();
}
if (dataTablesAjaxPostModel.Columns == null)
{
dataTablesAjaxPostModel.Columns = new List<DataTablesAjaxPostModel.ColumnData>();
}
if (dataTablesAjaxPostModel.Search == null)
{
dataTablesAjaxPostModel.Search = new DataTablesAjaxPostModel.SearchData()
{
Value = string.Empty
};
}
}
}
} We could ship this as a part of the library so people can include that if they want. Maybe rename it to I am still struggling with two ugly exceptions:
var ownedByColumn = request.Columns[x => x.OwnedBy];
ownedByColumn.ColumnSearchPredicate = (x) => x.OwnedBy.Name.Contains(ownedByColumn.SearchValue) ||
x.OwnedBy.EmailAddress.Contains(ownedByColumn.SearchValue);
ownedByColumn.ColumnOrderingProperty = (x) => x.OwnedBy.Name; And they did not provide OwnedBy, then BOOM it throws. So you have to try/catch every single place you configure some custom column searches. If they do not "ask" for the column in the request, we should find a way to not explode.
|
…when the developer tries to filter on a name that does not exist.
The constructor of DataTableRequest is doing a LOT. Can we break this up to better adhere to single responsibility? |
Sync with Parent
No description provided.