私はC#コードビハインドでlinqからエンティティへのクエリを介してSQL DBから場所のリストを取得するプログラムを持っています。このリストは、地図上の場所を表示するためにjavascriptメソッド(Google map api v3)によって解析する必要があります。私は、処理のためにサーバー側のクエリからjavascript関数に情報を取得する最善の方法を見つける必要があります。何かご意見は!?ASP.NETの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
良いチュートリアルを知りましたか? – SHeinema
あなたのニーズが単純な場合は、組み込みのものを使うことができます。http://msdn.microsoft.com/en-us/library/bb412179.aspx –
ok私はjsonのシリアル化をダウンしていると思いますが、それを渡すコードは何ですかクライアントに戻ってきますか? (申し訳ありませんasp.netに新しい...) – SHeinema