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?

时间: 2024-09-20 15:26:03

the differences of DataRelation class between 1.1 and 2.0的相关文章

WebGL and OpenGL Differences - 非2的次幂纹理的那些讲究儿

WebGL and OpenGL Differences WebGL is based on the OpenGL ES 2.0 specification, and retains the semantics of OpenGL ES in order to maximize portability to mobile devices. There are some significant differences in behavior of similar APIs between Open

C# struct class Differences

C# struct/class Differencesstruct Direct{ //...} class InDirect{ //...}Events are locked? Exist on stack or heap? Can cause garbage collection? Meaning of this? Always has a default constructor? Default construction triggers static construction? Can

C# struct &amp;amp; class Differences

C# struct/class Differences struct Direct {     //... } class InDirect {     //... } Events are locked?  Exist on stack or heap?  Can cause garbage collection?  Meaning of this?  Always has a default constructor?  Default construction triggers static

使用DataAdapter填充多个表(利用DataRelation)的实例代码_实用技巧

Default.aspx 复制代码 代码如下: View Code <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &q

beyound compare cmd differences but no orphans 的文件

问题描述 beyound compare cmd differences but no orphans 的文件 我需要用已经提取到的增量包来切割另一个folder, 获取增量包成功后,却没有办法在命令行下获取no orphan的结果. 那位大大有办法,请赐教了. 解决方案 How Do I Compare Two Files and Show The Differences? If, when you usefind, you discover two files with suspicious

用DataRelation给多个DataTable建立关系并显示到TreeView

DataRelation 对象执行两种功能: 它可使与正使用的记录相关的记录可用.如果在父记录 (GetChildRows) 中,则它提供子记录:如果正使用子记录 (GetParentRow),则它提供父记录. 它可强制约束的引用完整性,如删除父记录时删除相关的子记录. 了解真正的联接与 DataRelation 对象功能之间的差异很重要.在真正的联接中,从父表和子表获取记录并将其放入单个的平面记录集.当使用 DataRelation 对象时,不创建新记录集.而关系跟踪表之间的关系并使父记录和子

Create DataRelation ship between two tables

 There is a simple demo for DataRelation class of DataSet. while u can use DataTable.Select(conditions) or DataView.Filter to filete the data what you want .however,maybe the method is more complex with this one.           datatalbe performance test#

What are the differences between Akka and Netty?

        Akka is a concurrency framework built around the notion of actors and composable futures, Akka was inspired by Erlang which was built from the ground up around the Actor paradigm. It would usually be used to replace blocking locks such as syn

csharp: DataRelation objects to represent a parent/child/Level relationship

/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { var sections = new List<Section> { new Sec