C# Linq where clause as a variable

后端 未结 5 740
后悔当初
后悔当初 2020-12-01 07:30

I am trying to make a LINQ statement where the where clause comes from a variable. For example:

string whereClause = address.zip == 23456;
var x = from somet         


        
5条回答
  •  生来不讨喜
    2020-12-01 07:46

    Can try:

    var lstQ_Buffer = new List();
    

    Get

    lstQ_Buffer = unitOfWork.Q_BufferRepository.Get().ToList();
    

    Then apply where

    if (lstQ_Buffer.Count > 0)
    {
        lstQ_Buffer = lstQ_Buffer.Where(q => q.fkProgramId == programId && q.fkYearId == yearId && q.fkSemesterId == semesterId && q.fkCourse_ModuleId == courseModuleId && q.fkSubject_SpecialtyId == subjectSpecialtyId && q.fkSubSpecialtyId == subSpecialtyId && q.fkTopicId == topicId && q.fkSubTopicId == subTopicId && q.fkDifficultyLevelId == diffucultyLevelId).ToList();
    }
    

提交回复
热议问题