public T GetById(object id) { if (typeof(T).Equals(typeof(StudentModel))) { List <StudentModel> list = BinaryFileUtil.ReadFromFile <StudentModel>(); return(list.Find(x => x.Id == (int)id) as T); } else if (typeof(T).Equals(typeof(CourseModel))) { List <CourseModel> list = BinaryFileUtil.ReadFromFile <CourseModel>(); return(list.Find(x => x.Id == (int)id) as T); } else if (typeof(T).Equals(typeof(EmployeeModel))) { List <EmployeeModel> list = BinaryFileUtil.ReadFromFile <EmployeeModel>(); return(list.Find(x => x.Id == (int)id) as T); } T obj = default(T); obj = Activator.CreateInstance <T>(); return(obj); }
public IEnumerable <T> GetAll() { return(BinaryFileUtil.ReadFromFile <T>().AsEnumerable <T>()); }