【发布时间】:2012-02-15 11:15:42
【问题描述】:
我有一个程序,它通过 c# 代码隐藏中的 linq-to-entities 查询从 sql db 获取位置列表。此列表需要通过 javascript 方法(Google maps api v3)进行解析,以便在地图上显示位置。我需要找到从服务器端查询获取信息到 javascript 函数进行处理的最佳方法。有什么想法!?
编辑:序列化错误...
JavaScriptSerializer jss = new JavaScriptSerializer();
using (RamRideOpsEntities myEntities = new RamRideOpsEntities())
{
var validDates = (from a in myEntities.AdminOptions
select new { a.ValidDate1, a.ValidDate2 }).First();
var allWaitingRides = (from r in myEntities.Rides
where ((r.TimeOfCall >= validDates.ValidDate1 ||
r.TimeOfCall <= validDates.ValidDate2) && r.Status.Equals("Waiting", StringComparison.OrdinalIgnoreCase))
orderby r.TimeOfCall descending
select r).ToList();
json_topTen.Value = jss.Serialize(allWaitingRides.GetRange(0, 10).ToArray());
}
Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
Source Error:
Line 106: select r).ToList();
Line 107:
Line 108: json_topTen.Value = jss.Serialize(allWaitingRides.GetRange(0, 10).ToArray());
Line 109: }
Line 110: }
Source File: D:\DOCUMENTS\RamRide\RamRideOps_PL\RamRideOps\RamRideOps\Ops\DispatchCar.aspx.cs Line: 108
Stack Trace:
[ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.]
System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52
System.Collections.Generic.List`1.GetRange(Int32 index, Int32 count) +70
RamRideOps.DispatchCar.setTopTen() in D:\DOCUMENTS\RamRide\RamRideOps_PL\RamRideOps\RamRideOps\Ops\DispatchCar.aspx.cs:108
RamRideOps.DispatchCar.Page_Load(Object sender, EventArgs e) in D:\DOCUMENTS\RamRide\RamRideOps_PL\RamRideOps\RamRideOps\Ops\DispatchCar.aspx.cs:41
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
【问题讨论】:
标签: c# javascript asp.net google-maps-api-3 serverside-javascript