Passing multiple Lists in single parameter

prasad k 86 Reputation points
2021-02-05T12:37:27.297+00:00

Hi Team

I have below requirement.
'
There are 3 list with different class type.

Example:

List<Customer> lst1=new LIst<Customer>();
List<CustomerOrder> lst2=new List<CustomerOredr>();
List<CustomerTransaction> lst=new List<CustomerTransaction>();

i want to add three list into one list like ,List<List<T>> lstMul=New List<List<T>>();

lstMul.add(lst1);
lstMul.add(lst2);
lstMul.add(lst3);

Above lstMul will be send to the entity framework BulkInsertOrUpdate method

context.AddUpdateEntityData(lstMul)


ENtityframework method

    **public int AddUpdateEntityData(List<Dynamic> lstDynamic)**
    {

    _context.BulkInsertOrUpdate(lstDynamic.Item1);  ----Inserting Customer  List        
    _context.BulkInsertOrUpdate(lstDynamic.Item2);----inserting CustomerOrder List
    _context.BulkInsertOrUpdate(lstDynamic.Item3);-----inserting CustomerTransaction List
    _context.savechanges();

     return 1;

    }

Please suggest how we can achieve above reqirement.

Developer technologies | .NET | Entity Framework Core
Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Duane Arnold 3,216 Reputation points
    2021-02-05T16:08:22.58+00:00

    You can put all the Lists in a class, a container class/object and pass the container class/object as a parameter.

    A List<T> is a strong typed collection meaning if it's List<Book>, then only Book objects can be loaded into the List<Book>. You can't load a Car object into a List<Book>, becuase an exception will be thrown.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.