Mar 19, 2013

Generics

public abstract class BaseDao { public string GetConectionString() { return ""; } public abstract void Create(T t); public abstract T GetById(int id); public abstract List Search(SearchCriteria obj); } public class EmployeeDal : BaseDao { public override void Create(Employee t) { using (SqlConnection con = new SqlConnection(GetConectionString())) { } } public override Employee GetById(int id) { throw new NotImplementedException(); } public override List Search(SearchCriteria obj) { throw new NotImplementedException(); } } public class ITTicketsDal : BaseDao { public override void Create(Ticket t) { throw new NotImplementedException(); } public override Ticket GetById(int id) { using (SqlConnection con = new SqlConnection(GetConectionString())) { return null; } } public override List Search(SearchCriteria obj) { throw new NotImplementedException(); } } public class Employee { public string Name { get; set; } } public class Ticket { public string TicketId { get; set; } } public class SearchCriteria { public string FirstName { get; set; } public string LastName { get; set; } }

No comments: