/// <summary> /// Removes object from Database and checks count (should be "-1") /// </summary> /// <param name="data"></param> public bool DeleteTest(object data) { var count = gateway.LoadCount(data.GetType()); gateway.Delete(data); return(--count == gateway.LoadCount(data.GetType())); }
/// <summary> /// Exports the specified sheet to passed gateway and removes old data from passed gateway /// <example> /// <code> /// var target = new DbGateway(DbAccessor.Create("SampleDb")); /// var source = (ExcelAccessor)DbAccessor.Create("SampleExcelFile"); /// /// source.ExportWithClean<Contact>(target, "Contacts"); /// </code> /// </example> /// </summary> /// <typeparam name="T"></typeparam> /// <param name="sheetName">Name of the sheet.</param> /// <param name="targetGateway">The target gateway.</param> public void ExportWithClean <T>(DbGateway targetGateway, string sheetName) where T : class, new() { T[] list = LoadList <T>(sheetName); targetGateway.Delete(typeof(T)); targetGateway.Import(list); }