Data Collections

Alejandro Cernuda



Working with data collections sometimes leads to endless cycles and code inefficiency. In SQLClientCoreTool all CRUD operations can be implemented over data collections.

DataGather dataGather = DataGather.GetInstance(ConnectionString);

 

await dataGather.InsertListAsync(list);

await dataGather.UpdateManyAsync(list, null);

await dataGather.DeleteRangeAsync(list);


Note: To perform the above methods, there must be a table in the database named after the class that forms the collection, and the collection must have a primary key. Otherwise we would have to specify the name of the table. Perhaps it is better explained if we put the statement of one of the methods.

 /// <summary>

 /// Inserts an object into the Table named as objecttype.

 /// </summary>

 /// <param name="obj">Itstype has to match the name of the table in the database</param>

 /// <param name="tableName">Only if tableName is diferent to obj type name</param>

 /// <returns> if Table identity returns identityvalue else the number of inserted rows</returns>

 

    public asyncTask<int> InsertAsync(object obj, stringtableName = "")

        {

            return awaitTask.Run(() => Insert(obj, tableName));

        }