/// <summary> /// Returns the name of an existing table in the database that matches with the source /// one given, or with any of the candidates built using that source. /// </summary> internal static string FindTableName(IDataLink link, string source) { var names = new List<string>(); names.Add(source); names.AddRange(TableNameCandidates(source)); foreach (var name in names) { var found = false; var cmd = link.From(x => name).Top(1); var rec = (IRecord)null; var wasopen = link.IsOpen; try { rec = (IRecord)cmd.First(); found = true; } catch { } finally { if (rec != null) rec.Dispose(disposeSchema: true); if (cmd != null) cmd.Dispose(); if (!wasopen && link.IsOpen) link.Close(); } if (found) return name; } return null; }
/// <summary> /// Returns the name of an existing table in the database that matches with the source /// one given, or with any of the candidates built using that source. /// </summary> internal static string FindTableName(IDataLink link, string source) { var names = new List <string>(); names.Add(source); names.AddRange(TableNameCandidates(source)); foreach (var name in names) { var found = false; var cmd = link.From(x => name).Top(1); var rec = (IRecord)null; var wasopen = link.IsOpen; try { rec = (IRecord)cmd.First(); found = true; } catch { } finally { if (rec != null) { rec.Dispose(disposeSchema: true); } if (cmd != null) { cmd.Dispose(); } if (!wasopen && link.IsOpen) { link.Close(); } } if (found) { return(name); } } return(null); }