zoukankan      html  css  js  c++  java
  • the differences of DataRelation class between 1.1 and 2.0

    when u use the follow code on 1.1.it will compile without error. 

            /// <summary>
            
    /// Test table relation.
            
    /// </summary>

            public void Relation_1_1()
            
    {
                DataTable dtParent 
    = this.CreateDataTable();
                dtParent.TableName 
    = "Parent";

                DataRelation relations 
    = ds.Relations.Add("Relation", dtParent.Columns["index"], dtParent.Columns["parent_index"], false);

                
    this.builder.Append(" Get the data from tree ROOT.");
                
    this.GetLayerFromParent(ds, relations);
                
    this.PrintDataTable(ds.Tables["parent"]);

                
    this.builder.Append(" Get the data from tree CHILDS.");
                
    this.GetLayerFromChilds(ds, relations);
                
    this.PrintDataTable(ds.Tables["parent"]);

                
    this.DebugPrint(this.builder.ToString());
            }

    while it will run error on 2.0 with "Cannot create a DataRelation if Parent or Child Columns are not in a DataSet.".

    if u want to run normally,u can use this cod:

    /// <summary>
            
    /// Test table relation.
            
    /// </summary>

            public void Relation_2_0()
            
    {
                DataTable dtParent 
    = this.CreateDataTable();
                dtParent.TableName 
    = "Parent";

                DataSet ds 
    = new DataSet();
                ds.Tables.Add(dtParent);
                DataRelation relations 
    = ds.Relations.Add("Relation", ds.Tables["Parent"].Columns["index"], ds.Tables["Parent"].Columns["parent_index"], false);

                
    this.builder.Append(" Get the data from tree ROOT.");
                
    this.GetLayerFromParent(ds, relations);
                
    this.PrintDataTable(ds.Tables["parent"]);

                
    this.builder.Append(" Get the data from tree CHILDS.");
                
    this.GetLayerFromChilds(ds, relations);
                
    this.PrintDataTable(ds.Tables["parent"]);

                
    this.DebugPrint(this.builder.ToString());
                
                
    //this.WriteToTxtFile(this.builder.ToString());
            }

    what's your idea?

  • 相关阅读:
    jstl标签
    get和post
    try中的局部变量在finally中是找不到的。
    bzoj 4408: [Fjoi 2016]神秘数 数学 可持久化线段树 主席树
    ZOJ2112 BZOJ1901 Dynamic Rankings 树套树 带修改的区间第k小
    BZOJ 2120: 数颜色 带修改的莫队算法 树状数组套主席树
    POJ2104 K-th Number 不带修改的主席树 线段树
    POJ 2891 Strange Way to Express Integers 中国剩余定理 数论 exgcd
    POJ1151 Atlantis 水题 计算几何
    BZOJ 2333: [SCOI2011]棘手的操作 可并堆 左偏树 set
  • 原文地址:https://www.cnblogs.com/AloneSword/p/2237541.html
Copyright © 2011-2022 走看看