I have an Employee class like below
public class Employee
{
public int EmployeeID { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public DateTime DOB { get; set; }
}
I am using Entity Framework to retrieve the Employee data from the database like below
using (var dbContext = new EmployeeEntities())
{
List<Employee> employeeList = new List<Employee>();
employeeList = dbContext.employee.Select(x => new Employee
{
EmployeeID = x.EmployeeID,
Name = x.Name,
Age = x.Age,
DOB = x.DOB
}).ToList();
}
And then i serialize the list and save it as an XML file.
if (employeeList.Count > 0)
{
XmlSerializer mySerializer = new XmlSerializer(typeof(List<Employee>));
TextWriter myWriter = new StreamWriter("D:\\Employee.xml", true);
mySerializer.Serialize(myWriter, employeeList);
myWriter.Close();
}
My requirement here is to save the result set to Multiple XML files based on the page size that i specify. E.g if the Employee table contains 536 rows and my page size is 100, then i should save it in 6 XML files containing 100,100,100,100,100 and 36 rows respectively. How do i achieve this using entity framework??