使用Linq从表中获取价值

时间:2018-07-02 11:26:28

标签: c# asp.net linq

我正在使用以下linq语句:

public ActionResult Add()
    {
        var model = new AddScheduleViewModel();
        model.Schedule = GetDefaultValues();
        //model.Schedule.ScheduleID = 0;

        Entities entities = new Entities();

        var getJobList = entities.Jobs.ToList();
        SelectList list = new SelectList(getJobList, "JobId", "JobName");
        ViewBag.jobListName = list;

        ScheduleEntity db = new ScheduleEntity();

        var UserIden = User.Identity.GetUserId();

        ScheduleViewModel schedvm = new ScheduleViewModel();

        **var schedAccField = db.Schedule.Where(x => x.AspNetUsersId == UserIden).Select(x => x.AspNetUser.SchedAccuracy);**

如果AspNetUsersId等于当前登录用户的ID,请从AspNetUser表中的SchedAccuracy(一个int)获取值。但是,这不会获取该值,并返回错误“函数评估需要所有线程”。我该如何解决?

0 个答案:

没有答案