예제 #1
0
        public IEnumerable <string> Execute(TnsNamesQuery query)
        {
            if (string.IsNullOrEmpty(query.ProviderInvariantName))
            {
                throw new ArgumentNullException(nameof(query.ProviderInvariantName));
            }

            IEnumerable <string> tnsNames = Enumerable.Empty <string>();
            DbProviderFactory    factory  = DbProviderFactories.GetFactory(query.ProviderInvariantName);

            if (factory.CanCreateDataSourceEnumerator)
            {
                DbDataSourceEnumerator dsenum = factory.CreateDataSourceEnumerator();
                if (dsenum != null)
                {
                    DataTable dt   = dsenum.GetDataSources();
                    DataRow[] rows = dt.Select(null, "InstanceName", DataViewRowState.CurrentRows);

                    tnsNames = rows.Select(row => (string)row["InstanceName"]);
                }
            }

            return(tnsNames);
        }
예제 #2
0
 public Task <IEnumerable <string> > ExecuteAsync(TnsNamesQuery query)
 {
     throw new NotImplementedException();
 }