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?

  • 相关阅读:
    网络编程
    反射函数与元类
    面向对象进阶
    对象的封装与接口
    对象继承
    面向对象
    包,logging模块与haslib模块
    闭包函数及装饰器
    函数对象、函数的嵌套、名称空间及作用域
    函数简介及函数参数介绍
  • 原文地址:https://www.cnblogs.com/AloneSword/p/2237541.html
Copyright © 2011-2022 走看看