Ejemplo n.º 1
0
        public DomainObject GetOneForID(DomainObject odo)
        {
            try
            {
                command.CommandText = $"SELECT * FROM {odo.TableName} WHERE {odo.ConditionID}";
                reader = command.ExecuteReader();

                DataTable tabela = new DataTable();
                tabela.Load(reader);
                reader.Close();

                if (tabela.Rows.Count == 0)
                {
                    return(null);
                }
                else
                {
                    return(odo.ReadRowOfTable(tabela.Rows[0]));
                }
            }
            catch (Exception)
            {
                reader.Close();
                throw;
            }
        }
Ejemplo n.º 2
0
        public List <DomainObject> GetForCondition(DomainObject odo)
        {
            List <DomainObject> lists = new List <DomainObject>();

            try
            {
                command.CommandText = $"SELECT * FROM {odo.TableName} WHERE {odo.MainCondition}";
                reader = command.ExecuteReader();

                DataTable tabela = new DataTable();
                tabela.Load(reader);
                reader.Close();

                if (tabela.Rows.Count == 0)
                {
                    return(null);
                }

                foreach (DataRow row in tabela.Rows)
                {
                    lists.Add(odo.ReadRowOfTable(row));
                }

                return(lists);
            }
            catch (Exception)
            {
                reader.Close();
                throw;
            }
        }
Ejemplo n.º 3
0
        public List <DomainObject> GetAll(DomainObject domainObject)
        {
            List <DomainObject> lists = new List <DomainObject>();

            try
            {
                command.CommandText = $"SELECT * FROM {domainObject.TableName}";
                reader = command.ExecuteReader();

                DataTable table = new DataTable();

                table.Load(reader);

                foreach (DataRow row in table.Rows)
                {
                    lists.Add(domainObject.ReadRowOfTable(row));
                }

                reader.Close();

                return(lists);
            }
            catch (Exception)
            {
                reader.Close();
                throw;
            }
        }