public double Ratio(DisconnectedImportEntity orientative) { double total = orientative.Total !.Value; double result = 0; if ((RestoreDatabase.HasValue || SynchronizeSchema.HasValue) && orientative.RestoreDatabase.HasValue) //Optional { result += (orientative.RestoreDatabase.Value) / total; } if (!SynchronizeSchema.HasValue) { return(result); } result += (orientative.SynchronizeSchema !.Value) / total; if (!DisableForeignKeys.HasValue) { return(result); } result += (orientative.DisableForeignKeys !.Value) / total; result += Copies.Where(c => c.CopyTable.HasValue).Join( orientative.Copies.Where(o => o.CopyTable.HasValue && o.CopyTable.Value > 0), c => c.Type, o => o.Type, (c, o) => o.CopyTable !.Value / total).Sum(); if (!Copies.All(a => a.CopyTable.HasValue)) { return(result); } if (!Unlock.HasValue) { return(result); } result += (orientative.Unlock !.Value) / total; if (!EnableForeignKeys.HasValue) { return(result); } result += (orientative.EnableForeignKeys !.Value) / total; if (!DropDatabase.HasValue) { return(result); } result += (orientative.DropDatabase !.Value) / total; return(result); }
public double Ratio(DisconnectedExportEntity estimation) { double total = (long)estimation.Total !.Value; double result = 0; if (Lock != null) { return(result); } result += (estimation.Lock !.Value) / total; if (!CreateDatabase.HasValue) { return(result); } result += (estimation.CreateDatabase !.Value) / total; if (!CreateSchema.HasValue) { return(result); } result += (estimation.CreateSchema !.Value) / total; if (!DisableForeignKeys.HasValue) { return(result); } result += (estimation.DisableForeignKeys !.Value) / total; result += Copies.Where(c => c.CopyTable.HasValue).Join( estimation.Copies.Where(o => o.CopyTable.HasValue && o.CopyTable.Value > 0), c => c.Type, o => o.Type, (c, o) => o.CopyTable !.Value / total).Sum(); if (!Copies.All(a => a.CopyTable.HasValue)) { return(result); } if (!EnableForeignKeys.HasValue) { return(result); } result += (estimation.EnableForeignKeys !.Value) / total; if (!ReseedIds.HasValue) { return(result); } result += (estimation.ReseedIds !.Value) / total; if (!BackupDatabase.HasValue) { return(result); } result += (estimation.BackupDatabase !.Value) / total; if (!DropDatabase.HasValue) { return(result); } result += (estimation.DropDatabase !.Value) / total; return(result); }