This is how we can convert as Serializable which are written in Data Layer with Enterprise Library DAAB. All you need to do is make the Class and Connection object as Serializable.
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Text;using System.Data;using System.Data.Common;using Microsoft.Practices.EnterpriseLibrary.Data;using System.Runtime.Serialization;/// <summary>/// Summary description for DataLayer/// </summary>[Serializable]public class DataLayer : IDeserializationCallback{[NonSerialized]Database db;public DataLayer(){db = DatabaseFactory.CreateDatabase("DBConnectionString");}public DataTable GetClients(){DataTable result = new DataTable();DbCommand dbcommand = db.GetStoredProcCommand("GetAll_Clients");DataSet ds = db.ExecuteDataSet(dbcommand);if (ds.Tables.Count > 0){result = ds.Tables[0];ds = null;}return result;}#region IDeserializationCallback Membersvoid IDeserializationCallback.OnDeserialization(object sender){db = DatabaseFactory.CreateDatabase("DBConnectionString");}#endregion}
But you need to make all the data layer classes serializble this way to get the connection right.