OData Detla<Entity>Patch not updating - c#

I'm currently trying to hack Odata when updating.
I have the following model:
public class Patient
{
[DataMember]
[JsonPropertyName("id")]
public string Id { get; set; }
[DataMember]
[JsonPropertyName("name")]
public string? Name { get; set; }
[DataMember]
[JsonPropertyName("lastname")]
public string? LastName { get; set; }
[DataMember]
[JsonPropertyName("dateofbirth")]
public DateTime DateBirth { get; set; }
}
On the other hand, I have this controller:
[Route("api/v1/patient")]
public class PatientController:ODataController
{
List<Patient> patients = new List<Patient>()
{
new Patient()
{
Id = "1",
Name = "A name",
LastName = "A lastname"
},
new Patient()
{
Id = "2",
Name = "A second name",
LastName = "A second lastname"
}
};
[EnableQuery]
[HttpGet]
public async Task<IActionResult> GetAll()
{
return Ok(patients);
}
[EnableQuery]
[HttpGet("{id}")]
public async Task<IActionResult> Get([FromODataUri]string id)
{
Patient p = patients.SingleOrDefault(p => p.Id == id) ?? null;
if (p is null)
{
return NotFound();
}
return Ok(p);
}
[HttpPost]
public async Task<IActionResult> Post([FromBody]Patient patient)
{
var x = patients;
x.Add(patient);
return Ok(x);
}
[EnableQuery]
[HttpPatch("{id}")]
public async Task<IActionResult> Patch([FromODataUri] string id, [FromBody]Delta<Patient> patient)
{
if (!ModelState.IsValid)
{
throw new System.Web.Http.HttpResponseException(System.Net.HttpStatusCode.BadRequest);
}
Patient patientToEdit = patients.SingleOrDefault(p => p.Id == id) ?? null;
if (patientToEdit is not null)
{
patient.Patch(patientToEdit);
return Ok(patientToEdit);
}
else
{
return NotFound(patient);
}
}
}
However, the entity is not updating when calling with the following:
Json with name only and response not updating
The Program.cs file looks like the following:
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddHttpContextAccessor();
builder.Services.AddControllers().AddOData(options => options.Select().Expand().Filter().OrderBy().SetMaxTop(100).Count());
builder.Services.AddODataQueryFilter();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.UseRouting();
app.UseODataBatching();
app.UseODataQueryRequest();
app.UseODataRouteDebug();
app.Run();
The Delta patient is showing an empty list of changes when using patient.GetChangedPropertyNames();
Do you know how can I tackle this so I could perform partial patching?

Related

ASP.NET Core API using [ApiController], Parameter always null

I'm using ASP.NET Core to create a REST API. If I use the [APIController] class attribute, the method that uses the POST method with complex parameters always gets null value even though using/without using [FromBody] (I'm using Postman, Raw Json). But if I omit the [APIController] attribute, the parameters on the POST method work normally. I'm using ASP.NET Core 6. What is the effect without using the [APIController] attribute?
Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.Configure<Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions>(options =>
{
options.AllowSynchronousIO = true;
});
builder.Services.Configure<IISServerOptions>(options =>
{
options.AllowSynchronousIO = true;
});
// Add services to the container.
builder.Services.AddMvc(option =>
{
option.AllowEmptyInputInBodyModelBinding = true;
option.EnableEndpointRouting = true;
option.FormatterMappings.SetMediaTypeMappingForFormat("json", Microsoft.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"));
}).AddNewtonsoftJson(opt => {
opt.SerializerSettings.DateFormatString = "dd/MM/yyyy HH:mm:ss";
}).AddJsonOptions(options => {
options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
options.JsonSerializerOptions.PropertyNamingPolicy = null;
});
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddAuthentication();
builder.Services.AddAuthorization();
var app = builder.Build();
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.Run();
Model:
public class BillRequest
{
public string? CompCode { get; set; } = String.Empty;
public string? CustNo { get; set; } = String.Empty;
public string? ID { get; set; } = String.Empty;
public string? Type { get; set; } = String.Empty;
public string? TransDate { get; set; } = String.Empty;
public string? Remark { get; set; } = String.Empty;
public BillRequest()
{
}
}
Controller:
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
namespace FI.Controllers;
[ApiController]
[Route("[Controller]")]
public class VAController : ControllerBase
{
private readonly ILogger<VAController> _logger;
public VAController(ILogger<VAController> logger)
{
_logger = logger;
}
[HttpPost]
//[Authorize(AuthenticationSchemes = VAAuthSchemeConstants.VAAuthScheme)]
[Route("[Action]")]
public BillRequest Bills(BillRequest billReq)
{
try
{
if (ModelState.IsValid)
{
return new BillRequest
{
CompanyCode = "Test - success"
};
}
else
{
return new BillRequest()
{
CompanyCode = "Test - not valid model"
};
}
}
catch(Exception ex)
{
return new BillRequest()
{
CompCode = "Test - error"
};
}
}
}
Postman Payload (Postman Body (Raw, Json)):
{
"CompCode": "Test Comp"
"CustNo": "1235",
"ID": "123123123",
"Type": "01",
"TransDate": "Test Date",
"Remark": "My Remark"
}
Even though I changed the parameter using a string the parameter value is still null.

odata: How do I expand an nested ICollection of items using $expand in Odata using .net core 3.1

OData url:
https://{{baseUrl}}/api/vehicles?$expand=OwnershipHistories
I want to return a vehicle(s) and than $expand the OwnershipHistories as a List of owner ship histories.
But I only get one (1) Ownershiphistorie.
Question: Why can I not get all the ownership histories???
I have this on my controller:
[HttpGet]
[EnableQuery(PageSize = 10, MaxExpansionDepth = 20)]
[ODataRoute("vehicles")]
I use this url: {{baseUrl}}/api/vehicles?$expand=OwnershipHistories
I use the following c# code ():
public async Task<IQueryable<VehicleEntity>> GetVehicles()
{
var vehicles = _context.Vehicles; // .Include(v => v.OwnershipHistories) => ??? Is not working...
return vehicles;
}
The result is:
{
"#odata.context": "https://localhost:5001/api/$metadata#Vehicles(OwnershipHistories())",
"value": [
{
"id": 1,
"registrationNumber": "10STNV",
"vehicleIdentificationNumber": "JF1BP9LLA6G052053",
// more fields
"**OwnershipHistories**": [ ?????? Only **one** record, not the **8** records I expect ?????)
{
"VweID": 1,
"registrationNumber": "10STNV",
// more fields
}
]
},
}
This is the query for the database:
I have two entities and they are views in the sql database:
OwnershipHistoryEntity:
[Table("EigenaarsHistorie", Schema = "Voertuig")]
public class OwnershipHistoryEntity
{
[Key]
public int VweID { get; set; } // VDNI
// more fields
public virtual VehicleEntity Vehicle { get; set; }
}
VehicleEntity:
namespace VWE.MijnVWE.Vehicle.Api.DAL.Entities
{
[Table("VoertuigInformatie", Schema = "Voertuig")]
public class VehicleEntity
{
[Key]
public int VweID { get; set; } // VDNI
public string Kenteken { get; set; }
public string VoertuigIdentificatieNummer { get; set; }
// more fields
[ForeignKey("VweID")]
public ICollection<OwnershipHistoryEntity> OwnershipHistories { get; set; } = new List<OwnershipHistoryEntity>();
}
}
EdmModel builder:
using Microsoft.AspNet.OData.Builder;
using Microsoft.OData.Edm;
using VWE.MijnVWE.Vehicle.Api.DAL.Entities;
namespace VWE.MijnVWE.Vehicle.Api.BLL.Builders
{
public static class ModelBuilder
{
private static IEdmModel _edmModel;
public static IEdmModel GetEdmModel()
{
return GetExplicitEdmModel();
}
static IEdmModel GetExplicitEdmModel()
{
if (_edmModel == null)
{
var modelBuilder = new ODataConventionModelBuilder();
var vehicles = modelBuilder.EntitySet<VehicleEntity>("Vehicles");
var ownershipHistories = modelBuilder.EntitySet<OwnershipHistoryEntity>("OwnershipHistories");
modelBuilder.Namespace = "vwe.mijnvwe.vehicle";
modelBuilder.ContainerName = "vehicleApiContainer";
vehicles.EntityType.Name = "vehicles";
vehicles.EntityType.HasKey(k => k.VweID);
vehicles.EntityType.HasMany(v => v.OwnershipHistories);
vehicles.HasManyBinding(v => v.OwnershipHistories, "OwnershipHistories");
ownershipHistories.EntityType.Name = "ownershipHistories";
ownershipHistories.EntityType.HasKey(k => k.VweID);
ownershipHistories.EntityType.HasRequired(o => o.Vehicle, (o, t) => o.VweID == t.VweID);
vehicles.EntityType.Property(p => p.VweID).Name = "id";
vehicles.EntityType.Property(p => p.Kenteken).Name = "registrationNumber";
vehicles.EntityType.Property(p => p.VoertuigIdentificatieNummer).Name = "vehicleIdentificationNumber";
// more fields
ownershipHistories.EntityType.Property(p => p.Kenteken).Name = "registrationNumber";
ownershipHistories.EntityType.Property(p => p.EventDatum).Name = "eventDate";
ownershipHistories.EntityType.Property(p => p.SoortAansprReferentieCode).Name = "liabilityReferenceCode";
ownershipHistories.EntityType.Property(p => p.RegistratieDatumAansprakelijkheid).Name = "from";
ownershipHistories.EntityType.Property(p => p.RegistratieDatumAansprakelijkheidTot).Name = "to";
ownershipHistories.EntityType.Property(p => p.DagenInBezit).Name = "numberOfDays";
ownershipHistories.EntityType.Property(p => p.DatumGewijzigd).Name = "changedDateTime";
_edmModel = modelBuilder.GetEdmModel();
}
return _edmModel;
}
}
}
Ef core modelBuilder:
public class VehicleDbContext : DbContext
{
public VehicleDbContext(DbContextOptions<VehicleDbContext> options)
: base(options)
{ }
public DbSet<VehicleEntity> Vehicles { get; set; }
public DbSet<OwnershipHistoryEntity> OwnershipHistories { get; set; }
// more fields
protected override void OnModelCreating(ModelBuilder builder)
{
// ...
base.OnModelCreating(builder);
}
}
This is the Select query:
SELECT [t].[VweID], [t].[AandrijvingOmschrijving],
//more fields.. [t0].[SoortAansprReferentieCode], [t0].[c0]
FROM (
SELECT TOP(#__TypedProperty_3) [v].[VweID], [v].[AandrijvingOmschrijving], [v].[AantalAangedrevenAssen],
// more fields
[v].[Werkingsbeginsel], [v].[Wielbasis]
FROM [Voertuig].[VoertuigInformatie] AS [v]
ORDER BY [v].[VweID]
) AS [t]
OUTER APPLY (
SELECT TOP(#__TypedProperty_1) #__TypedProperty_2 AS [c], [e].[VweID], [e].[DagenInBezit], [e].[DatumGewijzigd], [e].[EventDatum], [e].[Kenteken], [e].[RegistratieDatumAansprakelijkheid], [e].[RegistratieDatumAansprakelijkheidTot], [e].[SoortAansprReferentieCode], CAST(1 AS bit) AS [c0]
FROM [Voertuig].[EigenaarsHistorie] AS [e]
WHERE [t].[VweID] = [e].[VweID]
ORDER BY [e].[VweID]
) AS [t0]
ORDER BY [t].[VweID], [t0].[VweID]
It is quit similar to the following question:
Same question about washington school odata question
Washington school code odata example

How do i confirm the action delete(POST) in my controller?

I have a ViewModel and I would like to make a fonctionnal delete(GET) and deleteConfirmed(POST) so i can delete what ever data is stored in my DB
I don’t know and would like to know what step to take to complete the deleteConfirmed. There is normally auto-generated code but it’s not what I need.
here is my ViewModel
using System;
using ExploFormsDB.Models;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace ExploFormsDB.ViewModels
{
public class WorkShiftDetailViewModel
{
[Key]
public int WorkShiftId { get; set; }
public int? HoleId { get; set; }
public string HoleName { get; set; }
public int SurveyLocationId { get; set; }
public int SupplierId { get; set; }
public int ZoneId { get; set; }
public string SurveyLocation1 { get; set; }
public string SupplierName { get; set; }
public string ZoneName { get; set; }
public DateTime StartDay { get; set; }
public DateTime EndDay { get; set; }
public ICollection<WorkerViewModel> WorkShiftEmployees { get; set; }
}
}
Here is my Controller, i have included the Create to help have a better understanding. GET: Delete seems to be working correctly, i am having trouble with the Post. any help what so ever will do. if the question as been answered already please send me a link. I'm pretty new to c# and core and completly new to ViewModels
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(WorkShiftDetailViewModel workShiftDetailViewModel)
{
if (!ModelState.IsValid)
{
WorkShift ws = new WorkShift();
ws.StartDay = workShiftDetailViewModel.StartDay;
ws.EndDay = workShiftDetailViewModel.EndDay;
ws.SupplierId = workShiftDetailViewModel.SupplierId;
ws.SurveyLocationId = 1;
ws.ZoneId = workShiftDetailViewModel.ZoneId;
ws.HoleId = workShiftDetailViewModel.HoleId;
_context.Add(ws);
await _context.SaveChangesAsync();
foreach (WorkerViewModel member in workShiftDetailViewModel.WorkShiftEmployees)
{
if (member.isDeleted == false) {
WorkShiftTeam emp = new WorkShiftTeam();
emp.EmployeeId = member.EmployeeId;
emp.RoleId = member.RoleId;
emp.WorkShiftId = ws.WorkShiftId;
_context.Add(emp);
}
}
HttpContext.Session.SetInt32("wsId", ws.WorkShiftId);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(CreateSharedView));
}
return View(workShiftDetailViewModel);
}
public IActionResult Delete(int? id)
{
if (id == null)
{
return NotFound();
}
List<WorkerViewModel> Workers = new List<WorkerViewModel>();
WorkShift ws = _context.WorkShift.Include(w => w.WorkShiftTeam).SingleOrDefault(x => x.WorkShiftId == id);
WorkShiftDetailViewModel detail = new WorkShiftDetailViewModel();
detail.HoleName = ws.HoleId == null ? "N/A" : _context.Hole.Find(ws.HoleId).HoleName;
detail.StartDay = ws.StartDay;
detail.EndDay = ws.EndDay;
detail.ZoneName = _context.Zone.Find(ws.ZoneId).ZoneName;
detail.SurveyLocation1 = _context.SurveyLocation.Find(ws.SurveyLocationId).SurveyLocation1;
detail.SupplierName = _context.Supplier.Find(ws.SupplierId).SupplierName;
detail.WorkShiftId = ws.WorkShiftId;
int order = 0;
var rolelist = new SelectList(_context.Role, "RoleId", "Role1");
var empsWithFullName = from e in _context.Employee.Where(a => a.IsActive)
select new
{
ID = e.EmployeeId,
FullName = e.LastName + ", " + e.FirstName
};
var empList = new SelectList(empsWithFullName, "ID", "FullName");
foreach (WorkShiftTeam member in ws.WorkShiftTeam.OrderBy(a => a.EmployeeId))
{
Workers.Add(new WorkerViewModel() { EmployeeId = member.EmployeeId, RoleId = member.RoleId, Index = order, Roles = rolelist, Employees = empList });
order++;
}
detail.WorkShiftEmployees = Workers;
return View(detail);
}
// POST: WorkShiftDetailViewModels/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
//??
} ```
Why you created an extra method for delete action as HttpGet? (that occurred conflict)
change it to:
[HttpGet]
public IActionResult GetById(int? id) { ... }
and just one delete method with this definition
[HttpPost]
public async Task<IActionResult> Delete(int? id) { ... }

EF Core: Updating One-to-Many Relationship dependent entity id

I am new in ASP.NET core and EF core. Please check my code and let me know what I am doing wrong.
** Foreign key constraint violation for AuthorId.
** BookCategory entity can not be tracked because another instance with same ID is being tracked
Book Model
public class Book
{
public int BookId { get; set; }
public string Title { get; set; }
public double Price { get; set; }
public int? Discount { get; set; }
public string ImagePath { get; set; }
public int? Stock { get; set; }
public Author Author { get; set; }
public int AuthorId { get; set; }
public BookCategory Category { get; set; }
public int? CategoryId { get; set; }
public ICollection<JoinBookTag> BookTags { get; set; }
}
BookCategory Model
public class BookCategory
{
public int Id { get; set; }
[Display(Name = "Category Name")]
public string CategoryName { get; set; }
public ICollection<Book> Books { get; set; }
}
Author Model
public class Author
{
public int AuthorId { get; set; }
public string Name { get; set; }
public ICollection<Book> Books { get; set; }
}
BookController
private readonly ApplicationDbContext _db;
private readonly HostingEnvironment _hostingEnvironment;
[BindProperty]
public BookViewModel ViewModel { get; set; }
public BookController(ApplicationDbContext db, HostingEnvironment host)
{
_db = db;
_hostingEnvironment = host;
ViewModel = new BookViewModel()
{
Book = new Models.Book(),
Authors = _db.Authors.ToList(),
BookCategories = _db.BookCategories.ToList(),
Tags = _db.Tags.ToList()
};
}
...............
[HttpGet]
public IActionResult Edit(int? id)
{
if (id == null)
{
return NotFound();
}
var book = _db.Books.Include(b => b.Category)
.Include(b => b.Author)
.SingleOrDefault(b => b.BookId == id);
if (book == null)
{
return NotFound();
}
ViewModel.Book = book;
return View(ViewModel);
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(BookViewModel model, int? id)
{
if (id == null)
{
return NotFound();
}
if (id != model.Book.BookId)
{
return NotFound();
}
if (!ModelState.IsValid)
{
/*ViewModel.Book = model.Book;
return View(ViewModel);*/
var errors = ModelState.Select(x => x.Value.Errors)
.Where(y => y.Count > 0)
.ToList();
return Json(new { errors });
}
var dbModel = _db.Books.Include(b => b.Category).Where(b => b.BookId == id).FirstOrDefault();
var file = HttpContext.Request.Form.Files;
if (file.Count > 0)
{
var RootDirectory = _hostingEnvironment.WebRootPath;
var extension = Path.GetExtension(file[0].FileName);
var filePath = Path.Combine(DataContext.ImageDirectory, model.Book.BookId + extension);
using (var fileStream = new FileStream(Path.Combine(RootDirectory, filePath), FileMode.Create))
{
file[0].CopyTo(fileStream);
}
dbModel.ImagePath = #"/" + filePath;
}
dbModel.AuthorId = model.Book.AuthorId;
dbModel.CategoryId = model.Book.CategoryId;
dbModel.Discount = model.Book.Discount;
dbModel.Price = model.Book.Price;
dbModel.Stock = model.Book.Stock;
dbModel.Title = model.Book.Title;
await _db.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
You need to add the key attribute on your id properties inside your models.
The next thing you need to update is tell _db to update your entity first then and only then save changes.
Why are you using async and await? Are these controller actions slowing down the UI?
Also can you post your book view model?
You action methods are wrong in certain places. Let me know if you want some more detailed advice.
[HttpGet]
public IActionResult Edit(int? id)
{
//Give this a name other than view model for example BookViewModel
ViewModel model = new ViewModel();
if (id == null)
{
return NotFound();
}
var book = _db.Books.Include(b => b.Category)
.Include(b => b.Author)
.SingleOrDefault(b => b.BookId == id);
if (book == null)
{
return NotFound();
}
model.Book = book;
return View(model);
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(BookViewModel model, int? id)
{
if (id == null || id != model.Book.BookId)
{
return NotFound();
}
if (ModelState.IsValid)
{
var dbModel = _db.Books.Include(b => b.Category).Where(b => b.BookId == id).FirstOrDefault();
var files = HttpContext.Request.Form.Files;
if (files.Any())
{
var RootDirectory = _hostingEnvironment.WebRootPath;
var extension = Path.GetExtension(files[0].FileName);
var filePath = Path.Combine(DataContext.ImageDirectory, model.Book.BookId + extension);
using (var fileStream = new FileStream(Path.Combine(RootDirectory, filePath), FileMode.Create))
{
file[0].CopyTo(fileStream);
}
dbModel.ImagePath = #"/" + filePath;
}
dbModel.AuthorId = model.Book.AuthorId;
dbModel.CategoryId = model.Book.CategoryId;
dbModel.Discount = model.Book.Discount;
dbModel.Price = model.Book.Price;
dbModel.Stock = model.Book.Stock;
dbModel.Title = model.Book.Title;
await _db.Books.UpdateAsync(dbModel);
await _db.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(model);
}

OData in .NET Core Web API Serialization for List / Dictionary

I'm using .NET Core 2.0.0 with https://www.nuget.org/packages/microsoft.aspnetcore.odata
This is my setup so far.
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
...
services.AddOData();
services.AddSingleton<IODataModelManger, ODataModelManager>(DefineEdmModel);
...
}
private ODataModelManager DefineEdmModel(IServiceProvider services)
{
var modelManager = new ODataModelManager();
var builder = new ODataConventionModelBuilder();
builder.EntitySet<TestDTO>(nameof(TestDTO));
builder.EntityType<TestDTO>().HasKey(ai => ai.Id); // the call to HasKey is mandatory
modelManager.AddModel(nameof(Something), builder.GetEdmModel());
return modelManager;
}
public void Configure(...)
{
...
var modelBuilder = new ODataConventionModelBuilder();
modelBuilder.EntitySet<TestDTO>("TestDTOs");
app.UseMvc(builder =>
{
builder.MapODataRoute("api", modelBuilder.GetEdmModel());
});
...
}
Controller
[HttpGet("all")]
public async Task<IQueryable<TestDTO>> Get()
{
// plug your entities source (database or whatever)
var test = await TestService.GetTest();
var modelManager = (IODataModelManger)HttpContext.RequestServices.GetService(typeof(IODataModelManger));
var model = modelManager.GetModel(nameof(Something));
var queryContext = new ODataQueryContext(model, typeof(TestDTO), null);
var queryOptions = new ODataQueryOptions(queryContext, HttpContext.Request, Provider);
return queryOptions
.ApplyTo(test, new ODataQuerySettings
{
HandleNullPropagation = HandleNullPropagationOption.True
}, null)
.Cast<TestDTO>();
}
Model
public class TestDTO : BaseEntityDTO
{
[Required]
public Guid Id { get; set; }
public List<CustomerDTO> Customers { get; set; }
public List<string> Tags { get; set; }
[JsonExtensionData]
public IDictionary<string, object> AddProperties { get; set; }
}
The problem is that with services.AddOData(); i only get return results with property Id, without services.AddOData(); I get all the properties json formatted.
How do I serialize also the List properties and maybe the Dictionary aswell?
Thanks.
This did the trick
var result = queryOptions
.ApplyTo(test, new ODataQuerySettings
{
HandleNullPropagation =
HandleNullPropagationOption.True
}, null)
.Cast<TestDTO>();
return Json(result);

Categories