Exemple #1
0
        public IList <T> RunSelect <T>(string selectQuery, string connectionString = null) where T : class
        {
            connectionString = connectionString ?? _connectionString;
            var result = new OrmSystem().PopulateDataset <T>(selectQuery, connectionString);

            return(result);
        }
Exemple #2
0
        public IList <T> GetById <T>(string tableName, int id, string connectionString = null) where T : class
        {
            string query = string.Format("SELECT * from {0} where Id = @id", tableName);

            connectionString = connectionString ?? _connectionString;

            var result = new OrmSystem().PopulateDataset <T>(query, connectionString);

            return(result);
        }
Exemple #3
0
        public IList <Portfolio> GetPortfolio(string accountNumber)
        {
            string query = string.Format("SELECT PurchaseDate, PurchasePrice, CurrentPrice , Name CompanyName, Industry CompanyIndustry, Number AccountNumber from Portfolio P inner join Companies C on C.Id = P.CompanyId inner join Accounts A on A.Id = P.AccountId where Number = @number");

            var result = new OrmSystem().PopulateDataset <Portfolio>(query, _connectionString, new List <RdbmsParameter> {
                new RdbmsParameter {
                    Name  = "@number",
                    Value = accountNumber
                }
            });

            return(result);
        }
Exemple #4
0
        public IList <Customer> GetCustomers(string name)
        {
            string query = "SELECT * from Customers where Name like @name";

            var result = new OrmSystem().PopulateDataset <Customer>(query, _connectionString, new List <RdbmsParameter>()
            {
                new RdbmsParameter {
                    Name  = "@name",
                    Value = string.Format("%{0}%", name)
                }
            });

            return(result);
        }
Exemple #5
0
        public IList <T> GetBy <T>(string tableName, Dictionary <string, object> parameters) where T : class
        {
            string whereClause = "";

            for (int i = 0; i < parameters.Count; i++)
            {
                whereClause = string.Format("{0}{1}", whereClause, i == 0 ? " where ": " and ");
                whereClause = string.Format("{0}{1}=@{1}", whereClause, parameters.ElementAt(i).Key);
            }

            string query = string.Format("SELECT * from {0} {1}", tableName, whereClause);

            var result = new OrmSystem().PopulateDataset <T>(query, _connectionString, parameters.Select(x => new RdbmsParameter
            {
                Name  = string.Format("@{0}", x.Key),
                Value = Convert.ToString(x.Value)
            }).ToList());

            return(result);
        }