MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

WCF

WCF Examples

WCF

WCF Projects

WCF Project

Data Sets and Tables
Previous Home Next

The raw DataSet and DataTable types are serializable, marked with the Serializable attribute:

[Serializable]
public class DataSet : ...
{...}

[Serializable]
public class DataTable : ...
{...}

 

We can define valid service contracts that accept or return data tables or data sets:

[DataContract]
struct Contact
{...}

[ServiceContract]
interface IContactManager
{
[OperationContract]
void AddContact(Contact contact);

[OperationContract]
void AddContacts(DataTable contacts);

[OperationContract]
DataTable GetContacts( );
}

Example:

[Serializable]
public partial class MyDataSet : DataSet
{
public ContactsDataTable Contacts
{get;}
[Serializable]
public partial class ContactsDataTable : DataTable,IEnumerable
{
public void AddContactsRow(ContactsRow row);
public ContactsRow AddContactsRow(string FirstName,string LastName);
//More members
}
public partial class ContactsRow : DataRow
{
public string FName
{get;set;}
public string LName
{get;set;}
//More members
}
//More members
}
public partial class ContactsTableAdapter : Component
{
public file MyDataSet.ContactsDataTable GetData( );
//More members
}
DataTableHelper

It requires is a converter from a data row in the table to the data contract. DataTableHelper also adds some compile-time and runtime type-safety verification

Exapmle: Using DataTableHelper

[DataContract]
struct Contact
{
[DataMember]
public string FName;
[DataMember]
public string LNamee;
}
[ServiceContract]
interface IContactManager
{
[OperationContract]
Contact[] GetContacts( );
...
}
class ContactManager : IContactManager
{
public Contact[] GetContacts( )
{
ContactsTableAdapter adapter = new ContactsTableAdapter( );
MyDataSet.ContactsDataTable contactsTable = adapter.GetData( );
Converter<MyDataSet.ContactsRow,Contact> converter;
Converter = delegate(MyDataSet.ContactsRow row)
{
Contact contact = new Contact( );
contact.FName = row.FName;
contact.LNamee  = row.LNamee;
return contact;
};
return DataTableHelper.ToArray(contactsTable,converter);
}
//Rest of the implementation
}
Previous Home Next