Ejemplo n.º 1
0
 /// <summary>
 /// 更据对象查询语句递归查询单个实体
 /// </summary>
 /// <param name="cmd">Command对象</param>
 /// <param name="oql">对象查询语句</param>
 /// <param name="parameters">参数列表</param>
 /// <param name="recursiveType">递归类型</param>
 /// <param name="recursiveDepth">递归深度</param>
 /// <returns>实体对象</returns>
 internal static JCUser SelectSingle(string oql, ParameterList parameters, RecursiveType recursiveType, int recursiveDepth)
 {
     using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
     {
         conn.Open();
         using (SqlCommand cmd = conn.CreateCommand())
         {
             return(ExcuteSelectSingleCommand(cmd, oql, parameters, recursiveType, recursiveDepth));
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 根据对象查询语句查询实体集合
 /// </summary>
 /// <param name="recursiveType">递归类型</param>
 /// <param name="recursiveDepth">递归深度</param>
 /// <returns>实体类对象集合</returns>
 internal static List <JCUser> Select(RecursiveType recursiveType, int recursiveDepth)
 {
     using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
     {
         conn.Open();
         using (SqlCommand cmd = conn.CreateCommand())
         {
             cmd.CommandText = "select * from JC_User";
             return(ExcuteSelectCommand(cmd, recursiveType, recursiveDepth));
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 执行Command获取对象列表
        /// </summary>
        /// <param name="cmd">Command对象</param>
        /// <param name="recursiveType">递归类型</param>
        /// <param name="recursiveDepth">递归深度</param>
        /// <returns>实体类对象列表</returns>
        internal static List <JCUser> ExcuteSelectCommand(SqlCommand cmd, RecursiveType recursiveType, int recursiveDepth)
        {
            List <JCUser> jCUserList = new List <JCUser>();

            using (SqlDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    JCUser jCUser = DataReaderToEntity(dr);
                    jCUserList.Add(jCUser);
                }
            }
            return(jCUserList);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 递归查询单个实体
        /// </summary>
        /// <param name="cmd">Command对象</param>
        /// <param name="recursiveType">递归类型</param>
        /// <param name="recursiveDepth">递归深度</param>
        /// <returns>实体对象</returns>
        internal static JCUser ExcuteSelectSingleCommand(SqlCommand cmd, RecursiveType recursiveType, int recursiveDepth)
        {
            JCUser jCUser = null;

            using (SqlDataReader dr = cmd.ExecuteReader())
            {
                if (dr.Read())
                {
                    jCUser = DataReaderToEntity(dr);
                }
            }
            if (jCUser == null)
            {
                return(jCUser);
            }
            return(jCUser);
        }
Ejemplo n.º 5
0
        public async Task ForcedParameterCustomTypeDeepDeserialization()
        {
            IScriptParser parser = new ScriptParser();

            parser.Types.AddType <RecursiveType>();

            Mock <IScriptCompiler> compiler = new Mock <IScriptCompiler>();

            compiler.Setup(s => s.CompileCode(It.IsAny <string>(), ScriptLanguage.NCScript)).Returns <string, ScriptLanguage>((code, language) => parser.Parse(code));
            compiler.Setup(s => s.CompileCodeAsync(It.IsAny <string>(), ScriptLanguage.NCScript)).Returns <string, ScriptLanguage>((code, language) => parser.ParseAsync(code));

            StartNode node = new StartNode(Guid.NewGuid(), "Start", new StartParameters {
                Parameters = new[] {
                    new ParameterDeclaration {
                        Name = "input",
                        Type = "recursivetype",
                    }
                }
            }, compiler.Object);

            Dictionary <string, object> variables = new Dictionary <string, object> {
                ["input"] = new Dictionary <string, object> {
                    ["Type"] = new Dictionary <string, object> {
                        ["Name"]  = "Peter",
                        ["Array"] = new[] {
                            new Dictionary <string, object> {
                                ["Name"] = "Bärbel"
                            }
                        }
                    }
                }
            };
            await node.Execute(new WorkflowInstanceState(new WorkflowIdentifier(), null, new StateVariableProvider(variables), s => null, null, null, false), CancellationToken.None);

            RecursiveType input = variables["input"] as RecursiveType;

            Assert.NotNull(input);
            Assert.NotNull(input.Type);
            Assert.NotNull(input.Type.Array);
            Assert.AreEqual("Peter", input.Type.Name);
            Assert.AreEqual(1, input.Type.Array.Length);
            Assert.AreEqual("Bärbel", input.Type.Array[0].Name);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 根据对象查询语句递归查询实体集合
 /// </summary>
 /// <param name="oql">对象查询语句</param>
 /// <param name="parameters">参数列表</param>
 /// <param name="recursiveType">递归类型</param>
 /// <param name="recursiveDepth">递归深度</param>
 /// <returns>实体类对象集合</returns>
 public static List<JCUser> Select(string oql, ParameterList parameters,RecursiveType recursiveType, int recursiveDepth)
 {
     return DJCUser.Select(oql, parameters, recursiveType, recursiveDepth);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 递归查询实体集合
 /// </summary>
 /// <param name="recursiveType">递归类型</param>
 /// <param name="recursiveDepth">递归深度</param>
 /// <returns>实体类对象集合</returns>
 public static List<JCUser> Select(RecursiveType recursiveType, int recursiveDepth)
 {
     return DJCUser.Select(recursiveType, recursiveDepth);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 递归查询单个实体
 /// </summary>
 /// <param name="cmd">Command对象</param>
 /// <param name="recursiveType">递归类型</param>
 /// <param name="recursiveDepth">递归深度</param>
 /// <returns>实体对象</returns>
 internal static JCUser ExcuteSelectSingleCommand(SqlCommand cmd,RecursiveType recursiveType,int recursiveDepth)
 {
     JCUser jCUser=null;
     using (SqlDataReader dr = cmd.ExecuteReader())
     {
         if(dr.Read())
             jCUser = DataReaderToEntity(dr);
     }
     if(jCUser==null)
         return jCUser;
     return jCUser;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 使用事务并按主键字段查询特定实体
 /// </summary>
 /// <param name="connection">连接对象</param>
 /// <param name="userID">主键值</param>
 /// <returns>实体类对象</returns>
 internal static JCUser SelectSingle(Connection connection,string userID, RecursiveType recursiveType, int recursiveDepth)
 {
     return SelectSingle(connection.Command, userID, recursiveType, recursiveDepth);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 按主键字段查询特定实体
 /// </summary>
 /// <param name="userID">主键值</param>
 /// <param name="recursiveType">递归类型</param>
 /// <param name="recursiveDepth">递归深度</param>
 /// <returns>实体类对象</returns>
 internal static JCUser SelectSingle(string userID, RecursiveType recursiveType, int recursiveDepth)
 {
     using(SqlConnection conn=new SqlConnection(Connection.ConnectionString))
     {
         conn.Open();
         using (SqlCommand cmd = conn.CreateCommand())
         {
             return SelectSingle(cmd,userID, recursiveType, recursiveDepth);
         }
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 更据主键值递归查询单个实体
 /// </summary>
 /// <param name="cmd">Command对象</param>
 /// <param name="userID">主键值</param>
 /// <param name="recursiveType">递归类型</param>
 /// <param name="recursiveDepth">递归深度</param>
 /// <returns>实体对象</returns>
 internal static JCUser SelectSingle(SqlCommand cmd, string userID,RecursiveType recursiveType,int recursiveDepth)
 {
     cmd.Parameters.Clear();
     if(userID==null)
     {
         cmd.CommandText = "select * from JC_User where UserID is null";
     }
     else
     {
         cmd.CommandText = "select * from JC_User where UserID=@pk";
         cmd.Parameters.Add(new SqlParameter("@pk",userID));
     }
     return ExcuteSelectSingleCommand(cmd, recursiveType, recursiveDepth);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 更据对象查询语句并启用事务查询单个实体
 /// </summary>
 /// <param name="connection">连接对象</param>
 /// <param name="oql">对象查询语句</param>
 /// <param name="parameters">参数列表</param>
 /// <returns>实体对象</returns>
 internal static JCUser SelectSingle(Connection connection, string oql, ParameterList parameters, RecursiveType recursiveType, int recursiveDepth)
 {
     return ExcuteSelectSingleCommand(connection.Command, oql, parameters, recursiveType, recursiveDepth);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 更据对象查询语句递归查询单个实体
 /// </summary>
 /// <param name="cmd">Command对象</param>
 /// <param name="oql">对象查询语句</param>
 /// <param name="parameters">参数列表</param>
 /// <param name="recursiveType">递归类型</param>
 /// <param name="recursiveDepth">递归深度</param>
 /// <returns>实体对象</returns>
 internal static JCUser SelectSingle(string oql, ParameterList parameters, RecursiveType recursiveType, int recursiveDepth)
 {
     using(SqlConnection conn=new SqlConnection(Connection.ConnectionString))
     {
         conn.Open();
         using (SqlCommand cmd = conn.CreateCommand())
         {
             return ExcuteSelectSingleCommand(cmd, oql, parameters, recursiveType, recursiveDepth);
         }
     }
 }
Ejemplo n.º 14
0
 /// <summary>
 /// 根据对象查询语句查询实体集合
 /// </summary>
 /// <param name="recursiveType">递归类型</param>
 /// <param name="recursiveDepth">递归深度</param>
 /// <returns>实体类对象集合</returns>
 internal static List<JCUser> Select(RecursiveType recursiveType, int recursiveDepth)
 {
     using(SqlConnection conn=new SqlConnection(Connection.ConnectionString))
     {
         conn.Open();
         using (SqlCommand cmd = conn.CreateCommand())
         {
             cmd.CommandText = "select * from JC_User";
             return ExcuteSelectCommand(cmd, recursiveType, recursiveDepth);
         }
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 /// 更据对象查询语句递归查询单个实体
 /// </summary>
 /// <param name="cmd">Command对象</param>
 /// <param name="oql">对象查询语句</param>
 /// <param name="parameters">参数列表</param>
 /// <param name="recursiveType">递归类型</param>
 /// <param name="recursiveDepth">递归深度</param>
 /// <returns>实体对象</returns>
 internal static JCUser ExcuteSelectSingleCommand(SqlCommand cmd, string oql, ParameterList parameters,RecursiveType recursiveType,int recursiveDepth)
 {
     //解析过滤部份Sql语句
     string filterString = SyntaxAnalyzer.ParseSql(oql, new JCUserMap());
     if(filterString!=string.Empty)
     {
         filterString=" where "+filterString;
     }
     cmd.CommandText = "select * from JC_User " + filterString;
     cmd.Parameters.Clear();
     //添加参数
     if (parameters != null)
     {
         foreach (string key in parameters.Keys)
         {
             cmd.Parameters.Add(new SqlParameter(key, parameters[key]));
         }
     }
     return ExcuteSelectSingleCommand(cmd, recursiveType, recursiveDepth);
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 更据对象查询语句递归查询单个实体
        /// </summary>
        /// <param name="cmd">Command对象</param>
        /// <param name="oql">对象查询语句</param>
        /// <param name="parameters">参数列表</param>
        /// <param name="recursiveType">递归类型</param>
        /// <param name="recursiveDepth">递归深度</param>
        /// <returns>实体对象</returns>
        internal static JCUser ExcuteSelectSingleCommand(SqlCommand cmd, string oql, ParameterList parameters, RecursiveType recursiveType, int recursiveDepth)
        {
            //解析过滤部份Sql语句
            string filterString = SyntaxAnalyzer.ParseSql(oql, new JCUserMap());

            if (filterString != string.Empty)
            {
                filterString = " where " + filterString;
            }
            cmd.CommandText = "select * from JC_User " + filterString;
            cmd.Parameters.Clear();
            //添加参数
            if (parameters != null)
            {
                foreach (string key in parameters.Keys)
                {
                    cmd.Parameters.Add(new SqlParameter(key, parameters[key]));
                }
            }
            return(ExcuteSelectSingleCommand(cmd, recursiveType, recursiveDepth));
        }
Ejemplo n.º 17
0
 /// <summary>
 /// 更据主键递归查询单个实体
 /// </summary>
 /// <param name="recursiveType">递归类型</param>
 /// <param name="recursiveDepth">递归深度</param>
 /// <returns>实体对象</returns>
 public static JCUser SelectSingle(string userID, RecursiveType recursiveType, int recursiveDepth)
 {
     return DJCUser.SelectSingle(userID, recursiveType, recursiveDepth);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// 执行Command获取对象列表
 /// </summary>
 /// <param name="cmd">Command对象</param>
 /// <param name="recursiveType">递归类型</param>
 /// <param name="recursiveDepth">递归深度</param>
 /// <returns>实体类对象列表</returns>
 internal static List<JCUser> ExcuteSelectCommand(SqlCommand cmd,RecursiveType recursiveType,int recursiveDepth)
 {
     List<JCUser> jCUserList = new List<JCUser>();
     using (SqlDataReader dr = cmd.ExecuteReader())
     {
         while (dr.Read())
         {
             JCUser jCUser = DataReaderToEntity(dr);
             jCUserList.Add(jCUser);
         }
     }
     return jCUserList;
 }