Esempio n. 1
0
        internal void Evaluate_ValidRuleAndConditions_ReturnsExpectedFuzzyOutput()
        {
            // Arrange
            var waterTemp = StubLinguisticVariableFactory.WaterTemp();
            var fanSpeed  = StubLinguisticVariableFactory.PumpSpeed();

            var fuzzyRule = new FuzzyRuleBuilder(PumpSpeedRule.Rule0)
                            .If(ConditionBuilder.If(waterTemp.Is(WaterTemp.Frozen)))
                            .Or(ConditionBuilder.If(waterTemp.Is(WaterTemp.Freezing)))
                            .Then(fanSpeed.Is(PumpSpeed.Off))
                            .Build();

            var dataPoint = new DataPoint(waterTemp.Subject, 0);

            var data = new Dictionary <Label, DataPoint> {
                { dataPoint.Variable, dataPoint }
            };

            // Act
            var result = fuzzyRule.Evaluate(data, new FuzzyEvaluator());

            // Assert
            Assert.Equal(fanSpeed.Subject, result[0].Subject);
            Assert.Equal(fanSpeed.GetState(0), result[0].State);
            Assert.Equal(UnitInterval.One(), result[0].FiringStrength);
            Assert.Equal(fanSpeed.GetSet(PumpSpeed.Off), result[0].OutputFunction);
        }
Esempio n. 2
0
        public static List <T> PageList <T>(this SqlConnection conn, ConditionBuilder condition, SortBuilder sort,
                                            int pageIndex, int pageSize, out int totalCount, SqlTransaction trans = null)
        {
            condition = condition ?? ConditionBuilder.New();
            sort      = sort ?? new SortBuilder();

            var info = EntityInfoContainer.Get(typeof(T));

            if (info.IsSoftDelete)
            {
                condition = condition.AndEqual("IsDel", false);
            }

            var sql = SqlServerSqlBuilder.PagingSelectWithTotalCount(info, condition.ToCondition(), sort.ToOrderBy(),
                                                                     pageIndex, pageSize);

            var parameters = condition.ToParameters();

            parameters.Add("RecordCount", dbType: DbType.Int32, direction: ParameterDirection.Output);

            var data = conn.Query <T>(sql, parameters, trans);

            totalCount = parameters.Get <int>("RecordCount");
            return(data.ToList());
        }
Esempio n. 3
0
        private void BuildWhere(string where = null)
        {
            if (where != null)
            {
                trackSql = trackSql.Replace("{where}", where);
                return;
            }
            if (whereExp == null)
            {
                trackSql = trackSql.Replace("{where}", "");
                return;
            }

            ConditionBuilder conditionBuilder = new ConditionBuilder();

            conditionBuilder.Build(whereExp.Body);

            //arg
            for (int i = 0; i < conditionBuilder.Arguments.Count(); i++)
            {
                args.Add("@q__" + i.ToString(), conditionBuilder.Arguments[i]);
            }
            //sql
            trackSql = trackSql.Replace("{where}", " where " + conditionBuilder.Condition);
        }
Esempio n. 4
0
 /// <summary>
 /// 绑定表格
 /// </summary>
 /// <param name="ParameterJson">查询条件</param>
 /// <param name="Gridpage">分页条件</param>
 /// <returns></returns>
 public virtual JsonResult GridPageJson(string ParameterJson, JqGridParam jqgridparam)
 {
     try
     {
         Stopwatch      watch    = CommonHelper.TimerStart();
         List <TEntity> ListData = new List <TEntity>();
         if (!string.IsNullOrEmpty(ParameterJson))
         {
             List <DbParameter> parameter = new List <DbParameter>();
             IList  conditions            = ParameterJson.JonsToList <Condition>();
             string WhereSql = ConditionBuilder.GetWhereSql(conditions, out parameter);
             ListData = repositoryfactory.Repository().FindListPage(WhereSql, parameter.ToArray(), ref jqgridparam);
         }
         else
         {
             ListData = repositoryfactory.Repository().FindListPage(ref jqgridparam);
         }
         var JsonData = new
         {
             total    = jqgridparam.total,
             page     = jqgridparam.page,
             records  = jqgridparam.records,
             costtime = CommonHelper.TimerEnd(watch),
             rows     = ListData,
         };
         return(Json(JsonData, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Esempio n. 5
0
 public void Test5()
 {
     var builder = new ConditionBuilder<SinglePerson2>(p => p.Id == 1);
     builder |= p => p.Id == 3;
     var user = SinglePerson2.FindOne(builder, p => p.Id);
     Assert.AreEqual("Tom", user.Name);
 }
Esempio n. 6
0
        public static int Delete <T, TPrimaryKey>(this SqlConnection conn,
                                                  ConditionBuilder condition,
                                                  Func <TPrimaryKey> getUserKeyFunc = null,
                                                  SqlTransaction trans = null)
        {
            var info = EntityInfoContainer.Get(typeof(T));

            if (!info.IsSoftDelete)
            {
                var sql = $"DELETE [{info.TableName}] WHERE {condition.ToCondition()}";
                return(conn.Execute(sql, condition.ToParameters(), trans));
            }

            if (info.IsDeleteAudit)
            {
                var userId = getUserKeyFunc != null?getUserKeyFunc.Invoke() : default;

                var sql   = $"UPDATE [{info.TableName}] SET IsDel=1,DeleteBy=@UserId,DeleteAt=GetDate() WHERE {condition.ToCondition()}";
                var param = condition.ToParameters();
                param.Add("UserId", userId);
                return(conn.Execute(sql, param, trans));
            }
            else
            {
                var sql = $"UPDATE [{info.TableName}] SET IsDel=1 WHERE {condition.ToCondition()}";
                return(conn.Execute(sql, condition.ToParameters(), trans));
            }
        }
Esempio n. 7
0
        //导出数据 By 阮创 2017/11/30
        public DataTable ExportExcel(string field)
        {
            string select = "SELECT * FROM";
            string from   =
                @"SELECT T1.F_NAME,
                     T1.F_CODE,
                     T1.F_SPEC,
                     T1.F_UNIT,
                   (CASE T1.F_ENABLE_MARK
                     WHEN 1 THEN
                      '有效'
                     WHEN 0 THEN
                      '无效'
                     ELSE
                      '类型错误'
                   END) AS F_ENABLE_MARK,
                   T1.F_CREATE_TIME
              FROM T_PRODUCT T1
             WHERE T1.F_DELETE_MARK = 0";

            if (!string.IsNullOrEmpty(field))
            {
                select = ConditionBuilder.GetSelectSql(field.JsonToList <Column>());
            }
            string sql = string.Format("{0} ({1})", select, from);

            return(Repository().FindTableBySql(sql));
        }
Esempio n. 8
0
        private async Task ReadJson(string wikiClass)
        {
            // for items that have the given class ...
            var conditions = new ConditionBuilder
            {
                { RdfItemClass, wikiClass }
            };
            // ... retrieve name and the icon url
            var task    = WikiApiAccessor.AskAndQueryImageInforUrls(conditions);
            var results = (await task).ToList();

            // download the images from the urls and save them
            foreach (var result in results)
            {
                var data = await HttpClient.GetByteArrayAsync(result.Url);

                foreach (var name in result.Names)
                {
                    var fileName = name + ".png";
                    WikiApiUtils.SaveImage(data, Path.Combine(SavePath, fileName), true);
                }
            }

            Log.Info($"Retrieved {results.Count} images for class {wikiClass}.");
        }
Esempio n. 9
0
        public void Test_InternalOr()
        {
            ConditionBuilder builder = new ConditionBuilder();

            builder.And(x =>
            {
                x.Or(y =>
                {
                    y.Equal("C.MemberId", "007")
                    .In("C.CheckFlag", new[] { 3, 4 })
                    .In("C.Flag", new[] { 1, 2 });
                })
                .Or(y =>
                {
                    y.NotEqual("C.MemberId", "007")
                    .Equal("C.CheckFlag", 4)
                    .Equal("C.Flag", 2);
                });
            });

            var result = builder.ToString();
            var param  = builder.GetParamDict().ToJson();

            Console.WriteLine(result);
            Console.WriteLine(param);
        }
Esempio n. 10
0
        internal void Build_WithComplexCondition_ReturnsExpectedFuzzyRule()
        {
            // Arrange
            var waterTemp = StubLinguisticVariableFactory.WaterTemp();

            // Act
            var rule1 = new FuzzyRuleBuilder("Rule1")
                        .If(ConditionBuilder
                            .If(waterTemp.Is("cold"))
                            .And(waterTemp.Not("freezing"))
                            .Or(waterTemp.Not("frozen")))
                        .And(ConditionBuilder
                             .If(waterTemp.Is("warm"))
                             .And(waterTemp.Not("hot"))
                             .Or(waterTemp.Not("boiling")))
                        .And(ConditionBuilder
                             .If(waterTemp.Is("frozen"))
                             .And(waterTemp.Is("warm")))
                        .Then(waterTemp.Not("frozen"))
                        .Build();

            var dataPoint = new DataPoint(waterTemp.Subject, 20);

            var data = new Dictionary <Label, DataPoint> {
                { dataPoint.Variable, dataPoint }
            };

            var result = rule1.Evaluate(data, new FuzzyEvaluator());

            var temp = waterTemp.GetState(2);

            // Assert
            //Assert.Equal(new FuzzyState("warm"), temp);
            //Assert.True(result);
        }
Esempio n. 11
0
        public DataTable Export(string field, string query)
        {
            string select = "SELECT * FROM", where = "WHERE 1=1";
            string from   =
                @"SELECT T1.*,
                   T2.F_NAME F_PART_NAME,
                   T2.F_SPEC F_PART_SPEC,
                   T2.F_UNIT F_PART_UNIT
              FROM T_PART_BUY T1
              LEFT JOIN V_PART T2
                ON T2.F_CODE = T1.F_PART_CODE
             WHERE T1.F_DELETE_MARK = 0";

            if (!string.IsNullOrEmpty(field))
            {
                select = ConditionBuilder.GetSelectSql(field.JsonToList <Column>());
            }
            if (!string.IsNullOrEmpty(query))
            {
                where += ConditionBuilder.GetWhereSql2(query.JsonToList <Condition>());
            }
            string sql = string.Format("{0} ({1}) TT {2}", select, from, where);

            return(Repository().FindTableBySql(sql));
        }
Esempio n. 12
0
        public List <T> Query <T>(Expression <Func <T, bool> > whereBy) where T : class, IDao, new()
        {
            var attr = GetTableAttr <T>();

            var sql = new StringBuilder();

            sql.Append($"SELECT {BuildSelectSqlColumn(attr)} FROM {attr.Name}");

            var condition = new ConditionBuilder();

            condition.Build(whereBy.Body);

            if (!string.IsNullOrEmpty(condition.Condition))
            {
                sql.Append(" WHERE " + condition.Condition);
            }

            if (!string.IsNullOrEmpty(attr.Sort))
            {
                sql.Append(" ORDER BY " + attr.Sort);
            }

            var list = _dapper.Query <T>(sql.ToString(), condition.DapperArguments).ToList();

            if (list.Count > 0)
            {
                list.ForEach(x => x.Inital());
            }

            return(list);
        }
Esempio n. 13
0
        public T Single <T>(Expression <Func <T, bool> > whereBy) where T : class, IDao, new()
        {
            var attr = GetTableAttr <T>();

            var sql = new StringBuilder();

            sql.Append($"SELECT {BuildSelectSqlColumn(attr)} FROM {attr.Name}");

            var condition = new ConditionBuilder();

            condition.Build(whereBy.Body);

            if (!string.IsNullOrEmpty(condition.Condition))
            {
                sql.Append(" WHERE " + condition.Condition);
            }

            if (!string.IsNullOrEmpty(attr.Sort))
            {
                sql.Append(" ORDER BY " + attr.Sort);
            }

            var instance = _dapper.QueryFirstOrDefault <T>(sql.ToString(), condition.DapperArguments);

            instance?.Inital();

            return(instance);
        }
Esempio n. 14
0
        public void Init()
        {
            IDataBaseDialect msSqlDialect        = new SqlServerFactory("O2O");
            IDialectBuilder  mssqlDialectBuilder = new DialectBuilder(msSqlDialect);

            _builder = new ConditionBuilder(mssqlDialectBuilder);
        }
Esempio n. 15
0
        private static MethodBuilder BuildEqualsMethod(
            string typeName,
            IReadOnlyList <PropertyDescriptor> properties)
        {
            const string other = nameof(other);

            ConditionBuilder equalCondition =
                ConditionBuilder
                .New()
                .SetReturn()
                .SetDetermineStatement();

            if (properties.Count == 0)
            {
                equalCondition.And("true");
            }
            else
            {
                foreach (PropertyDescriptor property in properties)
                {
                    equalCondition.And(ConditionBuilder
                                       .New()
                                       .Set(BuildPropertyComparison(property.Type, property.Name)));
                }
            }

            return(MethodBuilder
                   .New()
                   .SetName(nameof(IEquatable <object> .Equals))
                   .SetPublic()
                   .SetInheritance(Inheritance.Virtual)
                   .SetReturnType(TypeNames.Boolean)
                   .AddParameter(other, x => x.SetType(typeName.MakeNullable()))
                   .AddCode(CodeBlockBuilder
                            .New()
                            .AddCode(IfBuilder
                                     .New()
                                     .SetCondition(MethodCallBuilder
                                                   .Inline()
                                                   .SetMethodName(nameof(ReferenceEquals))
                                                   .AddArgument("null")
                                                   .AddArgument(other))
                                     .AddCode("return false;"))
                            .AddEmptyLine()
                            .AddCode(IfBuilder
                                     .New()
                                     .SetCondition(MethodCallBuilder
                                                   .Inline()
                                                   .SetMethodName(nameof(ReferenceEquals))
                                                   .AddArgument("this")
                                                   .AddArgument(other))
                                     .AddCode("return true;"))
                            .AddEmptyLine()
                            .AddCode(IfBuilder
                                     .New()
                                     .SetCondition($"{other}.GetType() != GetType()")
                                     .AddCode("return false;"))
                            .AddEmptyLine()
                            .AddCode(equalCondition)));
        }
Esempio n. 16
0
 public async Task <IActionResult> Get(ToggleLocator id)
 {
     return(new JsonResult(new
     {
         ConditionTypes = ConditionBuilder.AvailableTypes().OrderBy(n => n)
     }));
 }
Esempio n. 17
0
 public virtual JsonResult GridPageJson(string parameterJson, JqGridParam jqgridparam)
 {
     try
     {
         Stopwatch      watch    = CommonHelper.TimerStart();
         List <TEntity> ListData = new List <TEntity>();
         if (!string.IsNullOrEmpty(parameterJson))
         {
             List <DbParameter> parameter = new List <DbParameter>();
             IList  conditions            = parameterJson.JonsToList <Condition>();
             string WhereSql = ConditionBuilder.GetWhereSql(conditions, out parameter);
             ListData = Repositoryfactory.Repository().FindListPage(WhereSql, parameter.ToArray(), ref jqgridparam);
         }
         else
         {
             ListData = Repositoryfactory.Repository().FindListPage(ref jqgridparam);
         }
         var JsonData = new
         {
             total    = jqgridparam.total,
             page     = jqgridparam.page,
             records  = jqgridparam.records,
             costtime = CommonHelper.TimerEnd(watch),
             rows     = ListData,
         };
         return(Json(JsonData, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         BaseSysLogBll.Instance.WriteLog("", OperationType.Query, "-1", "异常错误:" + ex.Message + "\r\n条件:" + parameterJson);
         return(null);
     }
 }
Esempio n. 18
0
        /// <summary>
        /// 修改指定条件数据的指定字段
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TPrimaryKey"></typeparam>
        /// <param name="conn"></param>
        /// <param name="fieldValueList">
        ///     要修改的字段和值对,注意这里的Field是数据表的字段,而不是实体的属性
        ///     FieldValuePairs.New().Add(字段, 值).Add(...)
        ///     注意:此方法不会忽略已指定为UpdateIgnore的字段
        /// </param>
        /// <param name="condition"></param>
        /// <param name="getUserKeyFunc"></param>
        /// <param name="trans"></param>
        /// <returns></returns>
        public static int Set <T, TPrimaryKey>(this SqlConnection conn,
                                               FieldValuePairs fieldValueList,
                                               ConditionBuilder condition,
                                               Func <TPrimaryKey> getUserKeyFunc = null,
                                               SqlTransaction trans = null) where T : IBaseEntity <TPrimaryKey>
        {
            condition      = condition ?? ConditionBuilder.New();
            fieldValueList = fieldValueList ?? FieldValuePairs.New();

            var info = EntityInfoContainer.Get(typeof(T));

            var userId = getUserKeyFunc != null?getUserKeyFunc.Invoke() : default;

            if (info.IsUpdateAudit)
            {
                if (!fieldValueList.Exists(f => f.Field == "UpdateBy"))
                {
                    fieldValueList.Add("UpdateBy", userId);
                }

                if (!fieldValueList.Exists(f => f.Field == "UpdateAt"))
                {
                    fieldValueList.Add("UpdateAt", DateTime.Now);
                }
            }

            var stringParameter = fieldValueList.Invoke();

            var sql = SqlServerSqlBuilder.UpdateByCondition(info, stringParameter.Sql, condition.ToCondition());

            stringParameter.Parameters.AddDynamicParams(condition.ToParameters());

            return(conn.Execute(sql, stringParameter.Parameters, trans));
        }
Esempio n. 19
0
        /// <summary>
        /// Create  condition  with where  and args
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="where"></param>
        /// <param name="_whereExp"></param>
        /// <returns></returns>
        public static Tuple <string, DynamicParameters> BuildWhere <TResult>(Expression <Func <TResult, bool> > _whereExp, string where = null)
        {
            DynamicParameters args = new DynamicParameters();

            if (!string.IsNullOrEmpty(where))
            {
                return(new Tuple <string, DynamicParameters>(where, args));
            }
            if (_whereExp == null)
            {
                return(new Tuple <string, DynamicParameters>("", args));
            }

            ConditionBuilder conditionBuilder = new ConditionBuilder();

            conditionBuilder.Build(_whereExp.Body);

            //arg
            for (int i = 0; i < conditionBuilder.Arguments.Count(); i++)
            {
                args.Add("@q__" + i.ToString(), conditionBuilder.Arguments[i]);
            }
            //sql
            return(new Tuple <string, DynamicParameters>(" where " + conditionBuilder.Condition, args));
        }
Esempio n. 20
0
        private async Task <IEnumerable <XmlItemBase> > ReadJson(string wikiClass,
                                                                 Func <XmlItemBase, ItemType> itemTypeFunc, ItemCategory category)
        {
            var conditions = new ConditionBuilder
            {
                { RdfRarity, "Normal" },
                { RdfItemClass, wikiClass }
            };
            var printouts  = GlobalPredicates.Union(PredicatesPerCategory[category]);
            var enumerable =
                from result in await WikiApiAccessor.AskArgs(conditions, printouts)
                select PrintoutsToBase(category, result);

            var ret = enumerable.ToList();

            foreach (var item in ret)
            {
                item.ItemType = itemTypeFunc(item);
            }
            Log.Info($"Retrieved {ret.Count} bases of class {wikiClass}.");
            return
                (from b in ret
                 orderby b.ItemType, b.Level, b.Name
                 select b);
        }
Esempio n. 21
0
        //导出数据 By 阮创 2017/11/30
        public DataTable ExportExcel(string field)
        {
            string select = "SELECT * FROM";
            string from   =
                @"SELECT T1.F_PRODUCT_ID,
                     T1.F_QUANTITY,
                     T1.F_MAKE_DATE,
                   (CASE T1.F_ENABLE_MARK
                     WHEN 1 THEN
                      '有效'
                     WHEN 0 THEN
                      '无效'
                     ELSE
                      '类型错误'
                   END) AS F_ENABLE_MARK,
                    T2.F_NAME F_PRODUCT_NAME,
                   T1.F_CREATE_TIME
              FROM T_PRODUCT_MAKE T1
                LEFT JOIN T_PRODUCT T2 ON T1.F_PRODUCT_ID=T2.F_ID
             WHERE T1.F_DELETE_MARK = 0 AND T2.F_DELETE_MARK=0 AND T2.F_ENABLE_MARK=1";

            if (!string.IsNullOrEmpty(field))
            {
                select = ConditionBuilder.GetSelectSql(field.JsonToList <Column>());
            }
            string sql = string.Format("{0} ({1})", select, from);

            return(Repository().FindTableBySql(sql));
        }
Esempio n. 22
0
        /// <summary>
        /// 获取父节点列表Sql语句
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="fieldName">字段名</param>
        /// <param name="fieldValue">字段值</param>
        /// <param name="order">排序</param>
        /// <param name="idOnly">是否只需要主键</param>
        /// <param name="conditionBuilder">条件生成器</param>
        /// <returns></returns>
        public string GetParentsByCode(string tableName, string fieldName, string fieldValue, string order, bool idOnly = false,
                                       Action <IConditionBuilder> conditionBuilder = null)
        {
            StringBuilder sb = new StringBuilder();

            if (idOnly)
            {
                sb.AppendFormat("select {0} ", SqlBusinessLogicOptions.FieldId);
            }
            else
            {
                sb.Append("select * ");
            }
            sb.AppendFormat(" from {0} ", tableName);

            ConditionBuilder builder = new ConditionBuilder();

            builder.AppendRaw("(LEFT({0}, LEN({1})) = {1}) ", builder.AddParameter(fieldName, fieldValue), fieldName);
            conditionBuilder?.Invoke(builder);

            sb.Append(builder.ToString());

            _currentParamDict = builder.GetParamDict();

            sb.AppendFormat(" order by {0}", order);

            return(sb.ToString());
        }
Esempio n. 23
0
        public Toggle()
        {
            _tags             = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
            _conditions       = new ConditionCollection();
            _conditionBuilder = new ConditionBuilder();

            _currentConditionID = ConditionID.Empty;
        }
Esempio n. 24
0
        public void TestOrderBy1()
        {
            var conditionBuilder = ConditionBuilder <Account> .Create();

            conditionBuilder.OrderBy(x => new { x.Sex, x.Age });

            Assert.Fail("期望抛出NotSupportedException,但实际并没抛出异常");
        }
Esempio n. 25
0
        public void TestCreate()
        {
            var builder = ConditionBuilder <Account> .Create();

            var account = AccountRepository.Entities.FirstOrDefault(builder.Predicate);

            Assert.IsNotNull(account);
        }
        public void AddCondition(AdapterMethod sender, IReadOnlyDictionary <string, object> inputParams, IDictionary <string, object> outputParams)
        {
            var condition = new ConditionBuilder().BuildCondition((DeviceType)inputParams["SourceDeviceType"],
                                                                  (string)inputParams["SourceDevice"], (string)inputParams["TargetDevice"],
                                                                  (int)inputParams["RequiredValue"], (ConditionType)inputParams["ConditionType"], (int)inputParams["TargetValue"]);

            _conditionManager.RegisterCondition(condition);
        }
Esempio n. 27
0
        public ToggleView()
        {
            Tags       = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
            Conditions = new List <Condition>();

            _conditions       = new ConditionCollection(Conditions);
            _conditionBuilder = new ConditionBuilder();
        }
Esempio n. 28
0
        public IMessageWaiter <Task <IWaitResult> > NewExplicitWaiter(TimeSpan?defaultTimeout = null)
        {
            var conditionBuilder = new ConditionBuilder <Task <IWaitResult> >();
            var waiter           = new LocalMessagesWaiter <Task <IWaitResult> >(System, Transport, defaultTimeout ?? DefaultTimeout, conditionBuilder);

            conditionBuilder.CreateResultFunc = waiter.Start;
            return(waiter);
        }
Esempio n. 29
0
        public void Test5()
        {
            var builder = new ConditionBuilder <SinglePerson2>(p => p.Id == 1);

            builder |= p => p.Id == 3;
            var user = SinglePerson2.FindOne(builder, p => p.Id);

            Assert.AreEqual("Tom", user.Name);
        }
Esempio n. 30
0
 public SqlBuilder(IDialectBuilder dialect)
 {
     this._dialectBuilder = dialect;
     this._AT             = _dialectBuilder.DBDialect.VariableFormat;
     _RowVersion          = Settings.Timestamp;
     _lamdaBuilder        = new ConditionBuilder(dialect);
     _selectBuilder       = new SelectBuilder(dialect);
     _selectUpdateBuilder = new SelectUpdateBuilder(dialect);
 }
Esempio n. 31
0
        public void TestGetAccountPagingData()
        {
            var conditionBuilder = ConditionBuilder <Account> .Create();

            conditionBuilder.OrderBy(x => x.Sex).ThenBy(x => x.CreateTime);
            var pagingCondition = new PagingCondition(0, 15);

            Account.GetPagingDtoData <AccountDto>(pagingCondition, conditionBuilder);
        }
Esempio n. 32
0
 public void Test4()
 {
     var builder = new ConditionBuilder<SinglePerson2>(p => p.Id == 1);
     builder |= p => p.Id == 3;
     var list = SinglePerson2.Find(builder, p => p.Id);
     Assert.AreEqual(2, list.Count);
     Assert.AreEqual("Tom", list[0].Name);
     Assert.AreEqual("Mike", list[1].Name);
 }
Esempio n. 33
0
 public void Test1()
 {
     var builder = new ConditionBuilder<SinglePerson>();
     builder &= p => p.Id == 2;
     var condition = builder.ToCondition();
     var list = DbEntry.From<SinglePerson>().Where(condition).Select();
     Assert.AreEqual(1, list.Count);
     Assert.AreEqual("Jerry", list[0].Name);
 }
Esempio n. 34
0
 public void Test3()
 {
     var builder = new ConditionBuilder<SinglePerson>();
     builder &= p => p.Id == 1;
     builder |= p => p.Id == 3;
     var list = DbEntry.From<SinglePerson>().Where(builder).OrderBy(p => p.Id).Select();
     Assert.AreEqual(2, list.Count);
     Assert.AreEqual("Tom", list[0].Name);
     Assert.AreEqual("Mike", list[1].Name);
 }