@model IBCPackageTracking.Route @{ ViewBag.Title = "Route"; } <h2>Get Run Sheet for your Route</h2> <div class="content"> <div class="float-left"> <select id="SelectRoute" data-bind="options: routes, optionsText: 'rte_name', optionsCaption: 'Select a Route', optionsValue: 'rte_pk'"> </select> <p>Date: <input type="text" id="datepicker"></p> <div><input type="submit" value="Get Run Sheet" /></div> </div> </div> @section Scripts { @Scripts.Render("~/bundles/jqueryval") <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css"> <script> $(function () { $("#datepicker").datepicker(); }); </script> <script type="text/javascript" src="@Url.Content("~/Scripts/knockout-2.2.0.js")"></script> <script type="text/javascript"> // View-model will go here function RoutesViewModel() { var self = this; self.routes = ko.observableArray(); var baseUri = '@ViewBag.ApiUrl'; self.create = function (formElement) { // If the form data is valid, post the serialized form data to the web API. $(formElement).validate(); if ($(formElement).valid()) { $.post(baseUri, $(formElement).serialize(), null, "json") .done(function (o) { // Add the new product to the view-model. self.routes.push(o); }); } } self.update = function (route) { $.ajax({ type: "PUT", url: baseUri + '/' + route.Id, data: route }); } self.remove = function (route) { // First remove from the server, then from the view-model. $.ajax({ type: "DELETE", url: baseUri + '/' + route.Id }) .done(function () { self.products.remove(route); }); } $.getJSON(baseUri, self.routes); } $(document).ready(function () { ko.applyBindings(new RoutesViewModel()); }) </script>>
>db.Products.AsEnumerable(); >>
> var query = db.Products.AsQueryable(); //this does not execute the query > > if (productNameFilter != null > { > query = query.Where(p => p.ProductName == productNameFilter); //Still does not execute... > } > > return query.ToArray(); //The ToArray() kicks off the execution, because it takes it out of IQueryable data type. >>