【发布时间】:2013-02-14 21:19:47
【问题描述】:
首先我想向你们所有人道歉,因为我知道这个问题已经被问过很多次了。但我对 MVC 或 .NET 或 Lambda 表达式本身了解不多。我正在做一个小项目,但我遇到了 Lambda 表达式错误,如下所示
编辑 以下是控制器代码
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVC4Trial.Models;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
namespace MVC4Trial.Controllers
{
public partial class CallTrackController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Remote_Data()
{
return View("AjaxBinding");
}
public ActionResult vwCallDetails([DataSourceRequest] DataSourceRequest request)
{
return Json(GetCallDetailsFn().ToDataSourceResult(request));
}
private static IEnumerable<CallDetails> GetCallDetailsFn()
{
var callData = new CallTrackClassDataContext();
return callData.CallDetails.Select(calldetail => new CallDetails
{
CCCID = calldetail.CCCID,
Mp3_Url = calldetail.Mp3_Url,
Index = calldetail.Index,
Target_Number = calldetail.Target_Number,
Duration = calldetail.Duration,
LocalTime = calldetail.LocalTime,
Site_Name___Address = calldetail.Site_Name___Address,
Ad_Source_Name = calldetail.Ad_Source_Name,
Tracking_Number = calldetail.Tracking_Number,
Caller_Number = calldetail.Caller_Number,
Available_Feature = calldetail.Available_Feature
});
}
}
}
我想了解如何解决此错误。我在这里想念什么?我需要对我的模型/视图/任何其他文件进行任何类型的更改吗?感谢您的阅读和帮助。
【问题讨论】:
-
截图很好,但你能把代码的文本贴出来,这样其他人就不需要重新输入了吗?
-
“持续时间”行的错误是什么?我注意到其他错误会导致 linq 错误。
-
我注意到
Duration带有下划线 - 该属性有什么特别之处吗? -
感谢大家这么快就帮忙!
标签: c# asp.net-mvc lambda