string ISqlExpressionProvider.provideSql(DbList <DbParameter> dbParameters, DataOptType dataOptType, PList <Para> paraList, object[] methodParameters) { string ComNameEn = paraList["ComNameEn", true].ToString(); string sql = "select a.* from EmployeeInfo a, WorkInfo b where a.id=b.EmployeeInfoID and b.CompanyNameEn=@CompanyNameEn"; dbParameters.Add("CompanyNameEn", ComNameEn); return(sql); throw new NotImplementedException(); }
string ISqlExpressionProvider.provideSql(DbList <DbParameter> dbParameters, DataOptType dataOptType, PList <Para> paraList, object[] methodParameters) { DataEntity <DataElement> dataElements = paraList["dataElements", true].TryObject <DataEntity <DataElement> >(); string sql = "select a.* from EmployeeInfo a, WorkInfo b where a.id=b.EmployeeInfoID and b.CompanyNameEn=@CompanyNameEn"; dbParameters.Add("CompanyNameEn", dataElements["CompanyNameEn"].value); return(sql); throw new NotImplementedException(); }
/// <summary> /// 用数据实体中属于基本类型(int,string,bool等)的属性及其值来创建DbParameter集合 /// </summary> /// <param name="dataType">数据类型(数据实体属性类型)</param> /// <param name="dbTag">数据源参数类型(如:sqlserver参数类型为@, mysql参数类型为?, oracle为:)</param> /// <param name="data">数据源属性值</param> /// <param name="fieldName">sql语句中字段名称(同时也是数据实体属性名称)</param> /// <param name="dbParas">DbParameter集合</param> public void GetDbParaByBaseType(Type dataType, string dbTag, object data, string fieldName, DbList <DbParameter> dbParas) { if (!DJTools.IsBaseType(dataType)) { return; } object val = DJTools.ConvertTo(data, dataType); val = null == val ? DBNull.Value : val; dbParas.Add(fieldName, val); }
DbList <DbParameter> GetDbParameters(MethodInformation method, DataEntity <DataElement> dataElements, string sql) { DbList <DbParameter> dbParameters = new DbList <DbParameter>(); if (string.IsNullOrEmpty(sql)) { return(dbParameters); } if (null == dataElements) { return(dbParameters); } string msg = ""; Regex rg = DynamicCodeChange.rgParaField; if (rg.IsMatch(sql) && 0 < method.paraList.Count) { if (null == method.paraList[0].ParaValue) { msg = "The parameter value cann't be null."; ((AutoCall)method.AutoCall).e(msg); throw new Exception(msg); } string LeftSign = ""; string DbTag = ""; string FieldName = ""; string EndSign = ""; object v = null; string sql1 = sql; Match m = null; int num = 0; //DataEntity<DataElement> dataElements = (DataEntity<DataElement>)method.paraList[0].ParaValue; MatchCollection mc = rg.Matches(sql); while (rg.IsMatch(sql1) && 1000 > num) { if ((method.methodComponent.IsAsync || method.methodComponent.EnabledBuffer) && 0 < method.methodComponent.Interval) { Thread.Sleep(method.methodComponent.Interval); } m = rg.Match(sql1); LeftSign = m.Groups["LeftSign"].Value; if (!DynamicCodeChange.isEnabledField(LeftSign)) { continue; } DbTag = m.Groups["DbTag"].Value; FieldName = m.Groups["FieldName"].Value; EndSign = m.Groups["EndSign"].Value; v = dataElements[FieldName].value; dbParameters.Add(FieldName, v); sql1 = sql1.Replace(m.Groups[0].Value, ""); sql1 = EndSign + sql1; num++; } } return(dbParameters); }