示例#1
0
        public static bool ExecuteStaticPredicate
            (string expressions,
            int id1, bool boolType1, int intType1, string stringType1, DateTime dateTimeType1, DateTimeOffset datetimeOffsetType1, TimeSpan timeType1, Guid guidType1,
            int id2, bool boolType2, int intType2, string stringType2, DateTime dateTimeType2, DateTimeOffset datetimeOffsetType2, TimeSpan timeType2, Guid guidType2)
        {
            var tokens = ReversePolishNotation.GetTokens(expressions);

            var dict = new Dictionary <string, object>()
            {
                { "R.BoolType", boolType1 },
                { "R.IntType", id1 },
                { "R.StringType", stringType1 },
                { "R.DateTimeType", dateTimeType1 },
                { "R.DateTimeOffsetType", datetimeOffsetType1 },
                { "R.TimeType", timeType1 },
                { "R.GuidType", guidType1 },

                { "C.BoolType", boolType2 },
                { "C.IntType", id2 },
                { "C.StringType", stringType2 },
                { "C.DateTimeType", dateTimeType2 },
                { "C.DateTimeOffsetType", datetimeOffsetType2 },
                { "C.TimeType", timeType2 },
                { "C.GuidType", guidType2 },
            };

            return(true);

            return(ReversePolishNotation.Evaluate(tokens, dict));
        }
示例#2
0
        public static bool ExecutePredicate(string currentTableName, string contextTableName, string expressions,
                                            string rowIdentfierKeys, string contextIdentifierKeys)
        {
            var tokens     = ReversePolishNotation.GetTokens(expressions);
            var predicates = GetPredicates(tokens);

            var rowIdentifiers = GetIdentifiers(rowIdentfierKeys);
            var rowColumns     = GetColumns(predicates, VariableType.Row);

            var contextIdentifers = GetIdentifiers(contextIdentifierKeys);
            var contextColumns    = GetColumns(predicates, VariableType.Context);

            var resultValues = new Dictionary <string, object>();

            if (rowColumns.Count > 0)
            {
                resultValues = GetRowValues(currentTableName, rowIdentifiers, rowColumns).ToDictionary(key => "R." + key.Key, value => value.Value);
            }

            if (contextColumns.Count > 0)
            {
                var contextValues = GetRowValues(contextTableName, contextIdentifers, contextColumns).ToDictionary(key => "C." + key.Key, value => value.Value);

                foreach (var sqlResult in contextValues)
                {
                    resultValues.Add(sqlResult.Key, sqlResult.Value);
                }
            }


            return(ReversePolishNotation.Evaluate(tokens, resultValues));
        }