/// <summary> /// Delete for UserQuestion object /// if excepion happeneds during Table operation it must be cought in calling method. /// </summary> /// <param name="obj">instance of UserQuestion class to be inserted </param> /// <param name="AddToContext">bool paremeter tell the Context to attach object if it is not tracked by this instance of the Context </param> public void DeleteObject(UserQuestion obj, bool AddToContext) { if (AddToContext) servCtx.AttachTo(TableName, obj.InternalEntity, "*"); servCtx.DeleteObject(obj.InternalEntity); servCtx.SaveChangesWithRetries(); }
/// <summary> /// Insert for UserQuestion object /// if excepion happeneds during Table operation it must be cought in calling method. /// </summary> /// <param name="obj">instance of UserQuestion class to be inserted </param> public void AddObject(UserQuestion obj ) { servCtx.AddObject(TableName, obj.InternalEntity); servCtx.SaveChangesWithRetries(); }
internal List<UserQuestion> AssignQuestionsIds(string userid ) { UserQuestionContext uqc = new UserQuestionContext(); var quassign = uqc.GetAllForPartition(userid); if (quassign.Count == 0 ) { var rez = GetAll(); foreach (var item in rez) { UserQuestion uq = new UserQuestion(); uq.UserId = userid; uq.QuestionId = item.QuestionId; uq.CategoryId = item.CategoryId; uq.IsActive = true; uqc.AddObject(uq); } } quassign = uqc.GetAllForPartition(userid); return quassign.ToList<UserQuestion>(); }