Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
0
Answer
Compiled queries in LINQ
Yalavarthi Gopinath
7y
365
1
Reply
using
(TestAssessmentEntities context =
new
TestAssessmentEntities())
{
IQueryable result = MyCompliedQueries.cc(context, scheduleId);
return
result;
}
static
class
MyCompliedQueries
{
public
static
Func>
cc = CompiledQuery.Compile>((context, scheduleId) => (from sch
in
context.Schedule
where sch.Id == scheduleId && sch.ScheduleStatus == 2 && sch.DeliveryMode == 1
join tes
in
context.Test on sch.TestId equals tes.Id
join testsq
in
context.TestSectionQuestion on sch.TestId equals testsq.TestId
select
new
QuestionPaper
{
NoOfQestions = tes.NoOfQuestions,
MaxMarks = tes.MaxMarks,
TestSectionList = (from schh
in
context.Schedule
join testsec
in
context.TestSection on schh.TestId equals testsec.TestId
select
new
TestSectionList
{
SectionName = context.TestSection.Where(x => x.TestId == schh.TestId).Select(x => x.Name).ToList(),
Options = (from sc
in
context.Schedule
join ques
in
context.Question on testsq.QuestionId equals ques.Id
where ques.Id == testsq.QuestionId
select
new
Options
{
QuestionText = context.Question.Where(x => x.Id == testsq.QuestionId).Select(x => x.QuestionText).ToList(),
OptionText = context.QuestionOption.Where(x => x.QuestionId == ques.Id).Select(x => x.OptionText).ToList()
}).FirstOrDefault()
}).FirstOrDefault()
})).FirstOrDefault());
}
Displaying error as
can anyone please suggest me how to fix this issues related to compiled query
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
Given a collection of names, there may be a name 10 chars
linq query group by one column get multiple column