public async Task SaveAsync <T>(T poco) { var tableInfo = PocoDataFactory.TableInfoForType(poco.GetType()); if (await IsNewAsync(poco).ConfigureAwait(false)) { await InsertAsync(tableInfo.TableName, tableInfo.PrimaryKey, tableInfo.AutoIncrement, poco).ConfigureAwait(false); } else { await UpdateAsync(tableInfo.TableName, tableInfo.PrimaryKey, poco, null, null).ConfigureAwait(false); } }
/// <summary> /// Performs an SQL Insert /// </summary> /// <param name="poco">The POCO object that specifies the column values to be inserted</param> /// <returns>The auto allocated primary key of the new record, or null for non-auto-increment tables</returns> /// <remarks>The name of the table, it's primary key and whether it's an auto-allocated primary key are retrieved /// from the POCO's attributes</remarks> public Task <object> InsertAsync <T>(T poco) { var tableInfo = PocoDataFactory.TableInfoForType(poco.GetType()); return(InsertAsync(tableInfo.TableName, tableInfo.PrimaryKey, tableInfo.AutoIncrement, poco)); }
public Task <int> DeleteAsync(object poco) { var tableInfo = PocoDataFactory.TableInfoForType(poco.GetType()); return(DeleteAsync(tableInfo.TableName, tableInfo.PrimaryKey, poco)); }
public Task <int> UpdateAsync(object poco, object primaryKeyValue, IEnumerable <string> columns) { var tableInfo = PocoDataFactory.TableInfoForType(poco.GetType()); return(UpdateAsync(tableInfo.TableName, tableInfo.PrimaryKey, poco, primaryKeyValue, columns)); }