I am new in MVC. I want list view to generate by passing Date Parameter in controller; But I got error please help me solve the problem. my controller code is
- LPDBContext DB = new LPDBContext();
- var items = db.Processes.Where(x =>x.PRDate.ToShortDateString().Equals(08 / 09 / 2018)).ToList();
- return View(items);
- @model IEnumerable<EasyApp.Models.Process>
- @{
- ViewBag.Title = "ExportP3List";
- Layout = "~/Views/Shared/_Layout.cshtml";
- }
- <div class="EasyViewDiv table-responsive">
- <h2>Cuttingh2>
- <table style="font-size:smaller;" class="table table-bordered">
- <tr>
- <th>
- Production Date
- th>
- <th>
- In-Out Time
- th>
- <th>
- Employer
- th>
- <th>
- Operator Name
- th>
- <th>
- WO No
- th>
- <th>
- OD
- th>
- <th>
- Thk
- th>
- <th>
- Specification
- th>
- <th>
- Pipe No
- th>
- <th>
- Length
- th>
- <th>
- MT
- th>
- <th>
- Actual Meter
- th>
- <th>
- Time Taken
- th>
- <th>
- Speed
- th>
- tr>
- @foreach (var item in Model)
- {
- <tr>
- <td>
- @Html.DisplayFor(modelItem => item.PRDate)
- td>
- <td>
- @Html.DisplayFor(modelItem => item.Atten.INTIME) TO @Html.DisplayFor(modelItem => item.Atten.OUTIME)
- td>
- <td>
- @Html.DisplayFor(modelItem => item.Atten.Emp.CompanyID)
- td>
- <td>
- @Html.DisplayFor(modelItem => item.Atten.Emp.EmpName)
- td>
- <td>
- @Html.DisplayFor(modelItem => item.PipeAl.Order.WONO)
- td>
- <td>
- @Html.DisplayFor(modelItem => item.PipeAl.Order.DIA)
- td>
- <td>
- @Html.DisplayFor(modelItem => item.PipeAl.Order.THK)
- td>
- <td>
- @Html.DisplayFor(modelItem => item.PipeAl.Order.PISPEC)
- td>
- <td>
- @Html.DisplayFor(modelItem => item.PIPENO)
- td>
- <td>
- @Html.DisplayFor(modelItem => item.PipeAl.LENGTH)
- td>
- <td>
- @Html.DisplayFor(modelItem => item.PipeAl.MT)
- td>
- <td>
- @Html.DisplayFor(modelItem => item.ActualMeter)
- td>
- <td>
- @Html.DisplayFor(modelItem => item.CuttingTime)
- td>
- <td>
- @Html.DisplayFor(modelItem => item.CuttingSpeed)
- td>
- tr>
- }
- table>
- div>
I got following error
LINQ to Entities does not recognize the method 'System.String ToShortDateString()' method, and this method cannot be translated into a store expression.


Piyush PansuriyaRank #454 · 5.5K reputationPosted Sep 9, 2018, 8:41 PM EDT
Raju FodseRank #5,917 · 282 reputationPosted Sep 9, 2018, 10:15 PM EDT
LINQ to Entities does not recognize the method 'System.DateTime Parse(System.String)' method, and this method cannot be translated into a store expression.
Piyush PansuriyaRank #454 · 5.5K reputationPosted Sep 10, 2018, 8:38 PM EDT
Vivek KumarRank #272 · 9.3K reputationPosted Sep 9, 2018, 9:58 PM EDT
Raju FodseRank #5,917 · 282 reputationPosted Sep 11, 2018, 12:17 AM EDT
Raju FodseRank #5,917 · 282 reputationPosted Sep 16, 2018, 6:47 PM EDT
Hi All,
Ultimately I succeed to passing List view in MVC with “Hardcoded” Date Parameter