Reputation: 845
my project use ef and reposiroty for communication with database
when i find a record with the id
var applicant = applicantProvider.Get(1020);
Context.Set<TEntity>().Find(id);
then i got exception
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
Additional information: Year, Month, and Day parameters describe an un-representable DateTime.
the data record is :
id DOB SubmitDate CreateDate UpdateDate
1020 01/06/1949 2010-05-12 16:01:39 2010-05-14 16:59:10 2011-05-28 10:22:00
i don't know how i got that error pls help me
My entity Applicant
public class ABGApplicant
public int ABGApplicantID { get; set; }
public DateTime? DOB { get; set; }
public DateTime? SubmitDate { get; set; }
public DateTime? CreateDate { get; set; }
public DateTime? UpdateDate{ get; set; }
this is my main function
IABGApplicantProvider applicantProvider = new ABGApplicantProvider(new GenesisContext());
var applicant = applicantProvider.Get(1020);
this is my ABGApplicantProvider extend repository
public class ABGApplicantProvider : Repository<ABGApplicant>, IABGApplicantProvider
{
public ABGApplicantProvider(DbContext context) : base(context)
{
}
}
This is class Repository
public class Repository<TEntity> : IRepository<TEntity> where TEntity : class
public TEntity Get(int id)
{
// Here we are working with a DbContext, not PlutoContext. So we don't have DbSets
// such as Courses or Authors, and we need to use the generic Set() method to access them.
return Context.Set<TEntity>().Find(id);
}
Upvotes: 0
Views: 694
Reputation: 3778
I think your problem is not in your repository but in the data inside your DB...
Check the record with id=1020
and then check the column DOB
Upvotes: 1