public void AddForeignNetworkForCustomer(long ID, string ForeignID, Customer.ForeignUserTypes type) { CustomerForeignNetworkConnection f = new CustomerForeignNetworkConnection { CustomerID = ID, UserID = ForeignID, Type = (int)type }; // store it for both kinds of lookup: // * by foreign ID // * by customer ID // CustomerForeignNetworkConnectionDb fDB1 = new CustomerForeignNetworkConnectionDb(f, true); CustomerForeignNetworkConnectionDb fDB2 = new CustomerForeignNetworkConnectionDb(f, false); context.AttachTo(TableName, fDB1, null); context.AttachTo(TableName, fDB2, null); context.UpdateObject(fDB1); context.UpdateObject(fDB2); context.SaveChangesWithRetries(); context.Detach(fDB1); context.Detach(fDB2); }
public void RemoveForeignNetworkForCustomer(long ID, string ForeignID, Customer.ForeignUserTypes type) { CustomerForeignNetworkConnection f = new CustomerForeignNetworkConnection { CustomerID = ID, UserID = ForeignID, Type = (int)type }; CustomerForeignNetworkConnectionDb fDB1 = new CustomerForeignNetworkConnectionDb(f, true); CustomerForeignNetworkConnectionDb fDB2 = new CustomerForeignNetworkConnectionDb(f, false); context.AttachTo(TableName, fDB1); context.AttachTo(TableName, fDB2); context.DeleteObject(fDB1); context.SaveChangesWithRetries(); context.DeleteObject(fDB2); context.SaveChangesWithRetries(); }