private bool DeleteObjects <T>(LineObjectCollection <T> locLineObjects, TableSpecification ts) where T : IRemovableLineObject <T> { // DK - At the moment this method works ONLY with BIGINT type primary keys if (locLineObjects != null) { IdentityList il = new IdentityList(); try { foreach (IRemovableLineObject <T> obj in locLineObjects.Values) { il.AddUnique(obj.RemoveId); } DataCopy.ExecuteScalar(m_conn, m_transaction, "DELETE FROM {0} WHERE {1} IN ({2})", ts.TableName, ts.IdentityNames[0], il.FormatIds()); UpdateStatistic us = m_uss.EnsureStatistic(ts.TableName); us.DeleteCount = il.Count; return(true); } catch (Exception excp) { m_logger.Excp(excp, "DeleteObjects<{0}> ERROR. ObjectIds: {1}", typeof(T), il.FormatIds()); throw; } } return(false); }
public static long GetMaxLocalIdentity(IDbConnection conn, IDbTransaction transaction, string sTableName, string sLocalIdColumnName) { try { object objMax = DataCopy.ExecuteScalar(conn, transaction, "SELECT MAX({0}) FROM {1}", sLocalIdColumnName, sTableName); return(objMax == DBNull.Value ? 0 : Convert.ToInt64(objMax)); } catch (Exception excp) { m_logger.ErrorFormat("GetMaxLocalIdentity({0}, {1}) ERROR:{2}\r\n{3}", excp, sTableName, sLocalIdColumnName, excp.Message, excp.StackTrace); string sError = string.Format("Cannot get local MAX Identity for [{0}][{1}]", sLocalIdColumnName, sTableName); throw new System.Exception(sError); } }
public override void Delete(IDbConnection conn, IDbTransaction transaction) { DataCopy.ExecuteScalar(conn, transaction, "DELETE FROM {0} WHERE {1} = {2}", this.Table.TableName, this.Table.IdentityNames[0], this.ORMID); }