DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Mon, 09 Jul 2007 11:51:50 -0400,    posted on: microsoft.public.dotnet.framework.adonet        back       

Thread Index
  1    lucius am
          2    (WenYuan Wang [MSFT])
          3    (WenYuan Wang [MSFT])


Copy Entity Based on DataTable?   
I have some complex objects that inherit from DataTable. I want to
copy the actual data along with the custom properties and etc, so I
don't think I can use the .Copy() method in DataTable. Do I need to
override it in some way to make sure the object is truly copies to a
new instance when I need it?

Thanks.
Date:Mon, 09 Jul 2007 11:51:50 -0400   Author:  

RE: Copy Entity Based on DataTable?   
Hello Lucius,

According to your description, you need a method to copy the instance of 
class which inherited from DataTable. Did I misunderstand anything here? 
Please correct me. Thanks.

We need not override the base class's copy method, because the return type 
of the new method is different from the DataTable.Copy method.

public DataTable Copy()
{....}
public table2 Copy()
{....}

What we need to do is to create a new method named Copy and return a 
instance of class(inherited from DataTable). We could also get benefit from 
base.Copy method. This method will copy all columns and rows from the 
original instance. Then, we need set the other properties which we added 
into the class, and then return new instance.

For example:
Table2 is a new class which inherited from datatable. I added id and name 
as new properties.
class table2 : System.Data.DataTable
    {
        public int id;
        public string name;

Implementation of Copy() method, calls base.Copy to copy all the columns 
and rows and then set id and name.
        public table2 Copy()
        {
            table2 t = new table2();
            t = base.Copy() as table2;
            t.id = this.id;
            t.name = this.name;
            return t;
        }
}

Hope this helps.
Sincerely,
Wen Yuan
Microsoft Online Community Support 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Tue, 10 Jul 2007 07:46:16 GMT   Author:  

RE: Copy Entity Based on DataTable?   
Dear Lucius,

How are you? I just want to check if there is anything we can help with.
Please don't hesitate to let me know if you have anything unclear or any 
further issue. We are glad to assist you.

Have a great day,
Sincerely,
Wen Yuan
Microsoft Online Community Support 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Thu, 12 Jul 2007 10:17:52 GMT   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us