sqlsugar/Src/Asp.NetCore2/SqlSugar/DataSourceLoadOptionsExt/DataSourceLoadOptions.cs

36 lines
986 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NPlatform
{
using DevExtreme.AspNet.Data;
using DevExtreme.AspNet.Data.Helpers;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
[ModelBinder(BinderType = typeof(DataSourceLoadOptionsBinder))]
public class DataSourceLoadOptions : DataSourceLoadOptionsBase
{
}
public class DataSourceLoadOptionsBinder : IModelBinder
{
public Task BindModelAsync(ModelBindingContext bindingContext)
{
var loadOptions = new DataSourceLoadOptions();
DataSourceLoadOptionsParser.Parse(loadOptions, key => bindingContext.ValueProvider.GetValue(key).FirstOrDefault());
bindingContext.Result = ModelBindingResult.Success(loadOptions);
return Task.CompletedTask;
}
}
}