Synatx for fetching data using Generic and DataReader in DataAccess Layer.

public List<EmailTemplateBE> FetchEmailtemplate()

List<EmailTemplateBE> results = new List<EmailTemplateBE>();
SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings[“Test”].ConnectionString);
SqlCommand cmd = new SqlCommand(“TemplateFetch”, con);
cmd.CommandType = CommandType.StoredProcedure;
using (con)
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
EmailTemplateBE obj = new EmailTemplateBE();
obj.Id = (int)dr[“Id”];
obj.Title = (string)dr[“Title”];
obj.Description = (string)dr[“Description”];

return results;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: