/// <summary> /// Operates in an opposite capacity to its <see cref="AddToBlockedNameList(string)"/> /// in that only the names presented in <see cref="tblNames"/> will remain available /// and every table name found in <see cref="Sorting.AllTablesWithPkNames." /> /// and <see cref="Sorting"/>, not being found therein, will be added to the /// blocked name list. /// </summary> /// <param name="tblNames">An exclusive list of table names by which all others are blocked.</param> /// <returns>The count of names present in the blocked names list.</returns> /// <remarks> /// The idea here is that some databases will actually have more tables you know you don't want /// than those that you do so its easier to just list those tables you do want. /// </remarks> public static int SetExclusiveNameList(string[] tblNames) { if (tblNames == null || tblNames.Length <= 0) { return(0); } var pkTbls = Sorting.AllTablesWithPkNames; var noPkTables = Sorting.NoPkTablesNames; foreach (var tbl in pkTbls.Where(t => !DoNotReference.Any(x => String.Equals(x, t, StringComparison.OrdinalIgnoreCase)) && !tblNames.Any(x => String.Equals(x, t, StringComparison.OrdinalIgnoreCase)))) { var sameCaseTbl = pkTbls.FirstOrDefault(x => String.Equals(x, tbl, StringComparison.OrdinalIgnoreCase)); if (sameCaseTbl == null) { continue; } DoNotReference.Add(sameCaseTbl); } foreach (var tbl in noPkTables.Where(t => !DoNotReference.Any(x => String.Equals(x, t, StringComparison.OrdinalIgnoreCase)) && !tblNames.Any(x => String.Equals(x, t, StringComparison.OrdinalIgnoreCase)))) { var sameCaseTbl = pkTbls.FirstOrDefault(x => String.Equals(x, tbl, StringComparison.OrdinalIgnoreCase)); if (sameCaseTbl == null) { continue; } DoNotReference.Add(sameCaseTbl); } return(DoNotReference.Count); }
/// <summary> /// Operates to allow calling assembly to insert a name into the list of /// tables which should not be referenced. /// </summary> /// <param name="tblName"></param> /// <returns></returns> public static int AddToBlockedNameList(string tblName) { if (String.IsNullOrWhiteSpace(tblName) || DoNotReference.Contains(tblName)) { return(DoNotReference.Count); } DoNotReference.Add(tblName); return(DoNotReference.Count); }
/// <summary> /// Operates to allow calling assembly to insert many names into the list of /// tables which should not be referenced. /// </summary> /// <param name="tblNames"></param> /// <returns></returns> public static int AddToBlockedNameList(List <string> tblNames) { if (tblNames == null || tblNames.Count <= 0) { return(DoNotReference.Count); } foreach (var tbl in tblNames.Where(tblName => !DoNotReference.Contains(tblName))) { DoNotReference.Add(tbl); } return(DoNotReference.Count); }
/// <summary> /// Helper function which adds all <see cref="DoNotReference"/> which are blobs /// to the <see cref="Sorting.NoPkTablesNames"/> /// </summary> /// <returns></returns> public static int AddNoPkAllNonNullableToBlockedNameList() { var noPkTables = Sorting.NoPkTablesNames; if (noPkTables.Count <= 0) { return(DoNotReference.Count); } foreach ( var tblName in noPkTables.Where(Sorting.IsNoPkAndAllNonNullable) .Where(tblName => !DoNotReference.Contains(tblName))) { DoNotReference.Add(tblName); } return(DoNotReference.Count); }
/// <summary> /// For the calling assembly to know what is and isn't present therein. /// </summary> /// <returns></returns> public static string[] PrintBlockedNameList() { return(DoNotReference.ToArray()); }
/// <summary> /// Clears all table names from the internal list. /// </summary> public static void ClearBlockedNameList() { DoNotReference.Clear(); }