Click here to Skip to main content
16,004,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public class DataManager
{
    public static void OnlineExamLists(out List<MeritMaste_QuestionPaperSettings> examQuestionSettings, out List<MeritMaster_QuestionBank> questionBanks, string examCode)
     {
        using (var dbcontext = new meritmasterEntities())
        {
//here im getting error at conversion (below line)
            examQuestionSettings = (from k in dbcontext.MeritMaste_QuestionPaperSettings where k.Status == true && k.ex_code == examCode select k).ToList();
            var examsettingslocal = examQuestionSettings.FirstOrDefault();

            var kabqu = new List<MeritMaster_QuestionBank>();
            var queBank = examsettingslocal == null ? kabqu :
                (from k in dbcontext.MeritMaster_QuestionBank
                 where k.Status == true && k.Course_ID == examsettingslocal.CourseId
                 select k).ToList();

            var questionbanklocal = dbcontext.MeritMaste_QuestionPaperSettings.ToList();

            questionBanks = (from es in examQuestionSettings.ToList()
                             join qb in queBank.ToList() on new { p1 = (int)es.CourseId, p2 = (int)es.QuestionIds } equals new { p1 = (int)qb.Course_ID, p2 = (int)qb.ID }

                             where es.ex_code == examCode && es.Status == true && qb.Status == true
                            select qb).ToList();
        }
    }
}
}
Posted
v3
Comments
Tomas Takac 2-May-15 13:11pm    
Please copy & paste the error text into your question. The one in the title seems to have typos and is incomplete. Also specify on what line is the exception thrown. BTW what is "questionbanklocal" for?

1 solution

Check the Properties in MeritMaste_QuestionPaperSettings Class and Database fields for that Tables.
I think mismatch between the Properties and DataTypes of the column or Number of columns.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900