Example #1
0
        /// <inheritdoc/>
        public Dictionary <DataAccessContext, List <TableInfo> > GetAllTablesUsingCredentials(DataAccessCredentials credentials)
        {
            Dictionary <DataAccessContext, List <int> > toReturn = new Dictionary <DataAccessContext, List <int> >();

            toReturn.Add(DataAccessContext.Any, new List <int>());
            toReturn.Add(DataAccessContext.DataExport, new List <int>());
            toReturn.Add(DataAccessContext.DataLoad, new List <int>());
            toReturn.Add(DataAccessContext.InternalDataProcessing, new List <int>());
            toReturn.Add(DataAccessContext.Logging, new List <int>());

            using (var con = _repository.GetConnection())
            {
                using (var cmd = DatabaseCommandHelper.GetCommand(
                           "SELECT TableInfo_ID,Context FROM DataAccessCredentials_TableInfo WHERE DataAccessCredentials_ID = @cid",
                           con.Connection, con.Transaction))
                {
                    cmd.Parameters.Add(DatabaseCommandHelper.GetParameter("@cid", cmd));
                    cmd.Parameters["@cid"].Value = credentials.ID;

                    using (var r = cmd.ExecuteReader())
                        while (r.Read())
                        {
                            //get the context
                            DataAccessContext context = GetContext(r);

                            //add the TableInfo under that context
                            toReturn[context].Add((int)r["TableInfo_ID"]);
                        }
                }
            }

            return(toReturn.ToDictionary(k => k.Key, v => _repository.GetAllObjectsInIDList <TableInfo>(v.Value).ToList()));
        }