void IXapPoco.Delete <T>(T obj) { try { pocoMap = PocoMapService.Instance.GetPocoMap(obj); if (string.IsNullOrWhiteSpace(_dbConnectionContext.TSql)) { _dbConnectionContext.TSql = pocoMap.DeleteProcedure; } _dataProvider = DbFactory.Instance.Db(_dbConnectionContext); DoInsertUpdate(obj, PocoOperationType.Delete); _dataProvider.ExecuteNonQuery(); } catch (Exception ex) { throw new XapException($"Error performing delete for {typeof(T).FullName}", ex); } }
T IXapPoco.Insert <T>(T obj) { try { pocoMap = PocoMapService.Instance.GetPocoMap(obj); if (string.IsNullOrWhiteSpace(_dbConnectionContext.TSql)) { _dbConnectionContext.TSql = pocoMap.InsertProcedure; } _dataProvider = DbFactory.Instance.Db(_dbConnectionContext); DoInsertUpdate(obj, PocoOperationType.Insert); int idField = _dataProvider.ExecuteNonQuery(); obj.GetType()?.GetProperty(pocoMap.GetIdentityField()).SetValue(obj, idField); return(obj); } catch (Exception ex) { throw new XapException($"Error performing insert for {typeof(T).FullName}"); } }