Ejemplo n.º 1
0
        public void QueryByNotIn <T>(Expression <Func <T, object> > expression, SqlLamBase sqlQuery)
        {
            var fieldName = GetColumnName(expression);

            _builder.Not();
            _builder.QueryByIsIn(GetTableName <T>(), fieldName, sqlQuery);
        }
Ejemplo n.º 2
0
        public void ChangeSqlAdapter()
        {
            SqlLamBase.SetAdapter(SqlAdapter.SqlServer2008);

            var query = from product in new SqlLam <Product>()
                        orderby product.ProductName
                        select product;

            var queryString = query.QueryStringPage(10, 1);

            SqlLamBase.SetAdapter(SqlAdapter.SqlServer2012);

            Assert.IsTrue(queryString.Contains("ROW_NUMBER"));
        }
Ejemplo n.º 3
0
        public void QueryByIsIn(string tableName, string fieldName, SqlLamBase sqlQuery)
        {
            var innerQuery = sqlQuery.QueryString;

            foreach (var param in sqlQuery.QueryParameters)
            {
                var innerParamKey = "Inner" + param.Key;
                innerQuery = Regex.Replace(innerQuery, param.Key, innerParamKey);
                AddParameter(innerParamKey, param.Value);
            }

            var newCondition = $"{Adapter.Field(tableName, fieldName)} IN ({innerQuery})";

            WhereConditions.Add(newCondition);
        }
Ejemplo n.º 4
0
        public void QueryByIsIn(string tableName, string fieldName, SqlLamBase sqlQuery)
        {
            var innerQuery = sqlQuery.SqlString;
            var names      = sqlQuery.Parameters.ParameterNames;

            foreach (var name in names)
            {
                var param         = sqlQuery.Parameters.Get(name);
                var innerParamKey = "Inner" + param.Name;
                innerQuery = Regex.Replace(innerQuery, param.Name, innerParamKey);
                AddParameter(innerParamKey, param.Value);
            }

            var newCondition = string.Format("{0} IN ({1})", Adapter.Field(tableName, fieldName), innerQuery);

            _conditions.Add(newCondition);
        }
Ejemplo n.º 5
0
 public DefaultODataSqlBuilder()
 {
     SqlLamBase.SetAdapter(SqlAdapter.SqlServer2012);
 }
Ejemplo n.º 6
0
        public void QueryByIsIn <T>(bool isNot, Expression <Func <T, object> > expression, SqlLamBase sqlQuery)
        {
            var fieldName = GetColumnName(expression);

            _builder.AddCondition(isNot, GetTableName <T>(), fieldName, sqlQuery);
        }
        public void QueryByIsIn(string tableName, string fieldName, SqlLamBase sqlQuery)
        {
            var innerQuery = sqlQuery.QueryString;
            foreach (var param in sqlQuery.QueryParameters)
            {
                var innerParamKey = "Inner" + param.Key;
                innerQuery = Regex.Replace(innerQuery, param.Key, innerParamKey);
                AddParameter(innerParamKey, param.Value);
            }

            var newCondition = string.Format("{0} IN ({1})", Adapter.Field(tableName, fieldName), innerQuery);

            _conditions.Add(newCondition);
        }