• 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?

  • 相关阅读:
    QT5每日一学(五)QT布局管理器
    构造注入链:POP
    Jarvis OJ--PHPINFO
    XCTF(Web_php_unserialize)
    XCTF-反序列化中_wakeup()函数
    session反序列化
    PHP反序列化
    默认安装的phpMyAdmin会存在哪些安全隐患
    如何进行数据库备份
    开启mysql外部访问(root外连)
  • 原文地址:https://www.cnblogs.com/AloneSword/p/2237541.html
Copyright © 2020-2023  润新知