I got unique situation in my Entityframework web application, I'm trying to load the fields in page through list but its keep saying "The objectContext insteance has been disposed and can no longer be used for operations that require a connection." But when I set the debugging point and step into to see what is the error it works fine??
Here is my codes: This is Under my Page Load Event...
private void loadGPYouth(){ List
leader = GPYouthLoader.getGPYouth(ViewState["LeaderID"].ToString()); foreach (var item in leader) { ddlConstituency.SelectedValue = item.Grampanchayat.ConstituencyID.ToString(); ddlMandal.SelectedValue = item.Grampanchayat.MandalID.ToString(); //filling remaing fields..... }}This is under GPYouthLoader class :
public static List getGPYouth(string LeaderID){ List list = new List(); using (var db = new TDPMADANEntities()) { int _id = Convert.ToInt32(LeaderID); var query = (from b in db.GPYouths where b.YouthID == _id select b).ToList(); list = query.ToList(); } return list;}And This is my GPYouth class :
public partial class GPYouth{ public long YouthID { get; set; } public Nullable GPID { get; set; } //Remaining Fields.... public virtual Grampanchayat Grampanchayat { get; set; }}
View the original article here
ليست هناك تعليقات:
إرسال تعليق