public override BangoCommand GetItemCommand(DynamicDictionary data_param, string tableAlias = null) { BangoCommand cmd = new BangoCommand(); donation_request_links mdl = new donation_request_links(); tableAlias = tableAlias == null ? MainTableAlias : tableAlias; cmd.Template = cmd.SqlBuilder.AddTemplate(string.Format(@" select u.first_name || ' ' || u.last_name as full_name,u.contact_number,u.email from donation_details c INNER JOIN donation_request_links r on r.donation_id = c.id INNER JOIN rbac_user u on u.id=r.requested_user_id /**where**/ /**orderby**/" , mdl.GetTableName(), tableAlias)); //PropertyInfo prop = mdl.GetKeyPropertyInfo(); //cmd.SqlBuilder.Where(string.Format("{0}=@{0}", prop.Name), DbServiceUtility.ToDynamicParameter(prop.Name, id, DbServiceUtility.TypeMap[prop.PropertyType])); DbServiceUtility.BindDeleteParameter(cmd, mdl, tableAlias); DbServiceUtility.BindParameters(cmd, mdl, data_param, tableAlias, SearchTypes.Equal); if (CheckClientID) { PropertyInfo client_id = mdl.GetType().GetProperty("client_id"); if (client_id != null) { DbServiceUtility.BindClientIdParameter(cmd, mdl, tableAlias, DisplayMasterDataFromSystem); //string col = DbServiceUtility.SetColumnAlias(tableAlias, "client_id"); //cmd.SqlBuilder.Where("(client_id = 1 OR client_id = @client_id)"); //DynamicParameters param = new DynamicParameters(); //param.Add("@client_id", SessionData.client_id, DbType.Int32); //cmd.SqlBuilder.AddParameters(param); } } return(cmd); }
public virtual BangoCommand GetItemCommand(DynamicDictionary data_param, string tableAlias = null) { BangoCommand cmd = new BangoCommand(); TModel mdl = new TModel(); tableAlias = tableAlias == null ? MainTableAlias : tableAlias; cmd.Template = cmd.SqlBuilder.AddTemplate(string.Format(@" SELECT * FROM {0} {1} /**where**/ /**orderby**/" , mdl.GetTableName(), tableAlias)); //PropertyInfo prop = mdl.GetKeyPropertyInfo(); //cmd.SqlBuilder.Where(string.Format("{0}=@{0}", prop.Name), DbServiceUtility.ToDynamicParameter(prop.Name, id, DbServiceUtility.TypeMap[prop.PropertyType])); DbServiceUtility.BindDeleteParameter(cmd, mdl, tableAlias); DbServiceUtility.BindParameters(cmd, mdl, data_param, tableAlias, SearchTypes.Equal); if (CheckClientID) { PropertyInfo client_id = mdl.GetType().GetProperty("client_id"); if (client_id != null) { DbServiceUtility.BindClientIdParameter(cmd, mdl, tableAlias, DisplayMasterDataFromSystem); //string col = DbServiceUtility.SetColumnAlias(tableAlias, "client_id"); //cmd.SqlBuilder.Where("(client_id = 1 OR client_id = @client_id)"); //DynamicParameters param = new DynamicParameters(); //param.Add("@client_id", SessionData.client_id, DbType.Int32); //cmd.SqlBuilder.AddParameters(param); } } return(cmd); }
public virtual BangoCommand GetSearchCommand(SearchScenario scenario, DbConnect con, BangoCommand cmd, DynamicDictionary data_param, string selectClause, string orderByClause, int page = -1, int pageSize = 20, bool count = false, string tableAlias = null, string scenarioOthers = null) { TableDetailAttribute tableDetail = _model.GetTableDetail(); //clear the params whic are empty or null List <string> keys = new List <string>(data_param.KeyList.Cast <String>()); foreach (string key in keys) { object value = data_param.GetValue(key); if (value == null || data_param.GetValueAsString(key).Length == 0) { data_param.Remove(key); } } //BangoCommand cmd = GetSearchCommandTemplate(selectClause, count, tableAlias); //cmd.Sql.AppendLine("FROM " + model.GetTableName()); IDbExpression dbExp = App.Container.GetInstance <IDbExpression>(); if (data_param.GetCount() == 0) { return(cmd); } string append = DbServiceUtility.GetTableAliasForColumn(tableAlias); if (!(scenario == SearchScenario.TreeNode && count == false)) { //check & adding delete flag check sql DbServiceUtility.BindDeleteParameter(cmd, _model, tableAlias); if (CheckClientID) { DbServiceUtility.BindClientIdParameter(cmd, _model, tableAlias, DisplayMasterDataFromSystem); } //add remaining default search criteria cmd = BeforeBindingParameter(scenario, con, cmd, data_param, count, tableAlias); cmd = DbServiceUtility.BindParameters(cmd, _model, data_param, tableAlias); cmd = AfterBindingParameter(scenario, con, cmd, data_param, count, tableAlias); //check & adding order by clause if (count == false) { cmd = BeforeBindingOrderBy(scenario, con, cmd, data_param, count, tableAlias); cmd = DbServiceUtility.BindOrderBy(cmd, orderByClause); cmd = AfterBindingOrderBy(scenario, con, cmd, data_param, count, tableAlias); cmd = DbServiceUtility.BindPagination(cmd, page, pageSize); } } return(cmd); }
public override BangoCommand GetItemCommand(DynamicDictionary data_param, string tableAlias = null) { CheckClientID = false; BangoCommand cmd = new BangoCommand(); UserModel mdl = new UserModel(); tableAlias = tableAlias ?? MainTableAlias; cmd.Template = cmd.SqlBuilder.AddTemplate(string.Format(@"select c.*,t1.photo_url name_photo_url,t1.id photo_id,t1.file_name userfilename from rbac_user c LEFT JOIN tax_photos_files t1 on (c.id = t1.ref_id) /**where**/ AND t1.ref_id = @id /**orderby**/" , mdl.GetTableName(), tableAlias)); //PropertyInfo prop = mdl.GetKeyPropertyInfo(); //cmd.SqlBuilder.Where(string.Format("{0}=@{0}", prop.Name), DbServiceUtility.ToDynamicParameter(prop.Name, data_param.GetValueAsInt("id"), DbServiceUtility.TypeMap[prop.PropertyType])); DbServiceUtility.BindDeleteParameter(cmd, mdl, tableAlias); DbServiceUtility.BindParameters(cmd, mdl, data_param, tableAlias, SearchTypes.Equal); if (CheckClientID) { PropertyInfo client_id = mdl.GetType().GetProperty("client_id"); if (client_id != null) { DbServiceUtility.BindClientIdParameter(cmd, mdl, tableAlias, DisplayMasterDataFromSystem); //string col = DbServiceUtility.SetColumnAlias(tableAlias, "client_id"); //cmd.SqlBuilder.Where("(client_id = 1 OR client_id = @client_id)"); //DynamicParameters param = new DynamicParameters(); //param.Add("@client_id", SessionData.client_id, DbType.Int32); //cmd.SqlBuilder.AddParameters(param); } } return(cmd); }