public string GetOrAllocateMapping(string value, int projectNumber, UIDType uidType) { using (var con = _database.Server.GetConnection()) { con.Open(); var cmd = _server.GetCommand( "SELECT ReleaseUID from UIDMapping WHERE ProjectNumber = @ProjectNumber AND UIDType = @UIDType AND PrivateUID = @PrivateUID", con); _server.AddParameterWithValueToCommand("@ProjectNumber", cmd, projectNumber); _server.AddParameterWithValueToCommand("@UIDType", cmd, uidType); _server.AddParameterWithValueToCommand("@PrivateUID", cmd, value); var result = cmd.ExecuteScalar(); if (result == DBNull.Value || result == null) { var m = new UIDMapping(); m.UIDType = uidType; m.ProjectNumber = projectNumber; m.PrivateUID = value; m.ReleaseUID = GetKindaUid(); m.IsExternalReference = false; InsertMapping(m); return(m.ReleaseUID); } return(result.ToString()); } }
public void Update(UIDMapping mapping) { var table = _database.ExpectTable(_tableName); var sql = "UPDATE " + table.GetFullyQualifiedName() + " SET " + "PrivateUID = @PrivateUID, " + "ProjectNumber = @ProjectNumber, " + "UIDType = @UIDType, " + "IsExternalReference = @IsExternalReference " + "WHERE ReleaseUID = @ReleaseUID"; using (var conn = GetConnection()) { conn.Open(); var cmd = _server.GetCommand(sql, conn); _server.AddParameterWithValueToCommand("@PrivateUID", cmd, mapping.PrivateUID); _server.AddParameterWithValueToCommand("@ProjectNumber", cmd, mapping.ProjectNumber); _server.AddParameterWithValueToCommand("@UIDType", cmd, mapping.UIDType); _server.AddParameterWithValueToCommand("@IsExternalReference", cmd, mapping.IsExternalReference); _server.AddParameterWithValueToCommand("@ReleaseUID", cmd, mapping.ReleaseUID); cmd.ExecuteNonQuery(); } }
public void InsertMapping(UIDMapping mapping) { InsertMappings(new[] { mapping }); }