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); }
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); }
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); }
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); }
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); }