Below code is
used to convert Entity Object to DataSet.
- Create Book.cls
- Serializing using XmlSerializer
- Create Book.cls
2. Create console application for Serializing using XmlSerializerusing System;using System.Collections.Generic;
using System.Linq;
using System.Text;
public class Book{
public string FirstName;
public string MI;
public string LastName;
}
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using System.Data;
class Program{
Book objbooks;
static void Main(string[] args)
{
fnserialise();
}
static void fnserialise(){
Book objbooks = new Book();
objbooks.FirstName = "Ram";
objbooks.LastName = "Kumar";
objbooks.MI = "A";
XmlSerializer serializer;
MemoryStream stream;
serializer = new XmlSerializer(objbooks.GetType());
stream = new MemoryStream();
serializer.Serialize(stream, objbooks);
DataSet BookData = new DataSet("Books");
stream.Position = 0;
BookData.ReadXml(stream);
stream.Close();
}
No comments:
Post a Comment