SELECT A.*,IFNULL(B.QuestionCount,0) AS QuestionCount
FROM RB_Question_Bank AS A LEFT JOIN( SELECT BankId,COUNT(1) AS QuestionCount FROM rb_question WHERE `Status`=0 GROUP BY BankId) AS B ON A.BankId=B.BankId
WHERE 1=1");
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Question_Bank_ViewModel.Status),(int)DateStateEnum.Normal);
if(query==null)
{
returnnewList<RB_Question_Bank_ViewModel>();
}
else
{
if(query.BankId>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Question_Bank_ViewModel.BankId),query.BankId);
}
if(!string.IsNullOrEmpty(query.BankName))
{
builder.AppendFormat(" AND A.{0} LIKE @BankName ",nameof(RB_Question_Bank_ViewModel.BankName));