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.          /**////         /// Test table relation.

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?

目录
相关文章
|
2月前
|
Go Python
Classes & OOP--Defining Your Own Exception Classes
Classes & OOP--Defining Your Own Exception Classes
15 2
JavaFX报错:Class FIFinderSyncExtensionHost is implemented in both
JavaFX报错:Class FIFinderSyncExtensionHost is implemented in both
79 0
|
JavaScript
Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-
Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-
Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-
|
TensorFlow 算法框架/工具 Python
Taking advantage of context features
In the featurization tutorial we incorporated multiple features beyond just user and movie identifiers into our models, but we haven't explored whether those features improve model accuracy.
207 0
No enclosing instance of type SmsUtils is accessible. Must qualify the allocation with an enclosing
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px '.SF NS Text'} No enclosing instance of type SmsUtils is accessible. Must qualify the allocation with an enclosing instance of type SmsUtils (e.g. x.new A() where x is an instance of SmsUtils). 今天在写一个短信发送的工具类时使用到了内部类,在实例化内部类时遇到此错误。
1459 0
笔记:Six Pointers for Creating Strong Operational Business Values
这篇文章讲的是关于怎样创造强壮而且可操作的商业价值的六点内容,有些新意,不过最后意思的是这张图,这张图一个自上而下的组织的示意图,搞得好传神,够我笑一天的: 其他的: Key Takeaways Businesses need to take into account that the future will be driven by a millennial workforce.
1936 0