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.

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
697 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,222 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Duane Arnold 3,211 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