Unable to get data using BulkRead method of EFCore.BulkExtensions

2.1k views Asked by At

Hope you are doing well.

I'm using EFCore.BulkExtensions[3.1.6] in .Net Core 3.1 Web API to perform bulk operations. Bulk insert and update are working fine but I'm not able to use BulkRead method to get the bulk data.

I refer this link https://github.com/borisdj/EFCore.BulkExtensions#read-example and tried it but I'm not getting data. Maybe I didn't understand the example.

Here is the code which I've tried:

    IList<VehicleSubModel> submodels = new List<VehicleSubModel>(); // VehicleSubModel is the domain Entity

        var result = submodels.Select(s => new VehicleSubModel() { Id = s.Id, Name = s.Name }).ToList();
        var bulkConfig = new BulkConfig { UpdateByProperties = new List<string> { nameof(VehicleSubModel.Id), nameof(VehicleSubModel.Name) } };

        await Task.Run(() => Context.BulkRead(result, bulkConfig));

I want to get Id and Name of all VehicleSubModel but it's not returning any record. Could anyone please explain how we can use the BulkRead method of EFCore.BulkExtensions. I spend several hours to get it done, search many links but not getting its solution. Can anyone please help?

0

There are 0 answers