我試圖把我的lambda字符串與+
標誌放在一起,它不會讓我運行代碼,因爲它說無效表達式!Lambda concatenation
頂端Code
的using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using Certifications.Data;
using Certifications.Models;
using Microsoft.EntityFrameworkCore.Internal;
namespace Certifications.Controllers
{
public class Managerial : Controller
{
private readonly CertificationContext _context;
public Managerial(CertificationContext context)
{
_context = context;
}
過濾
// Approval Filter
string ApprovalFilterBuild = "";
if (approval == "Approved")
{
ApprovalFilterBuild = ".Where(i => i.Approved == true);";
}
if (approval == "Revoked")
{
ApprovalFilterBuild = ".Where(i => i.Approved == false);";
}
if (approval == "ALL")
{
ApprovalFilterBuild = "";
}
查詢
var certificationContext = _context.INT_CertificationsXREF
.Include(i => i.INT_CertificationCategories)
.Include(i => i.INT_Certifications)
.Include(i => i.INT_CertificationConferred)
.Include(i => i.RIM_Resource)
+ApprovalFilterBuild+
.Where(i => i.RIM_Resource.LAN == i.RIM_Resource.LAN)
.Where(i => LANlist.Contains(i.RIM_Resource.LAN));
return View(await certificationContext.ToListAsync());
既然你什麼時候可以Concat的實際代碼簡單的字符串? –
您試圖將'Expression'與'string'連接起來,但不能。 – tchelidze
那麼你會如何做到這一點?我只是一名實習生。 –