Date parameter is not working Properly

Analyst_SQL 3,551 Reputation points
2023-03-14T08:31:07.04+00:00

I am using linq ,in which date parameter is not working

   public ActionResult BBDetail(DateTime? start, DateTime? end)
        {

            var list = new List<ProbaleMV>();

            List<ItemMasterFile> tblitem = DB.ItemMasterFiles.ToList();
            List<Section> tblsection = DB.Sections.ToList();
            List<Catagory> tblcategory = DB.Catagories.ToList();
            List<Probale> tblprobale = DB.Probales.ToList();
            var bbigbalerecord = from e in tblprobale
                                  where e.EntryDate >= start && e.EntryDate <= end && e.DelID != null
                                  join d in tblitem on e.Codeitem equals d.CodeItem into table1
                                  from d in table1.ToList()
                                  join i in tblsection on e.SecID equals i.SecID into table2
                                  from i in table2.ToList()
                                  join c in tblcategory on e.CID equals c.CID into table3
                                  from c in table3.ToList()
                            
                                
                                 select new BBDetailView
                                 {
                                     probale = e,
                                     itemname = d,
                                     section = i,
                                     catagory = c
                                 };
            return View(bbigbalerecord);









        }

View

@model IEnumerable<ERP_APP.Models.BBDetailView>

@{

}

<div class="card">
    <div class="card-header">
        <div class="text-sm">
            <div class="card-title">Item List</div>
        </div>
    </div>
    <div class="card-body">
        @Html.ActionLink("Create New", "CreaterEmployee", null, new { @class = "btn btn-primary" })
        @using (Html.BeginForm("BBDetail", "BigBale", FormMethod.Post))
        {
            <hr />

            <div class="form-horizontal">
                <div class="form-group form-group-sm">
                    <div class="col-md-8">

                        @*<input name="start" type="date" id="datepicker" class="form-control" />*@
                        <input name="start" type="date" id="start" class="form-control" value="@Request["start"]" />
                    </div>
                </div>
                <div class="form-group form-group-sm">
                    <div class="col-md-8">
                        <input name="end" type="date" id="end" class="form-control" value="@Request["end"]" />
                        @*<input name="end" type="date" id="datepicker" class="form-control" />*@
                    </div>
                </div>
                <div class="form-group-sm">
                    <div class="col-md-offset-2 col-md-10">
                        <input type="submit" value="Get" onclick="SubmitForm()" class="btn btn-default" /> <span> </span>
                    </div>
                </div>
            </div>
        }
        <table class="table table-striped my-4 w-100" id="datatable2">
            <thead>
                <tr>
                    <th>
                        @Html.DisplayNameFor(model => model.itemname.Descriptionitem)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.section.Secnam)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.probale.EntryDate)
                    </th>
                    <th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr>
                        <td>
                            @Html.DisplayFor(modelItem => item.itemname.Descriptionitem)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.section.Secnam)
                        </td>
                        <td>

                            @Convert.ToDateTime(item.probale.EntryDate).ToString("dd/MM/yyyy")
                        </td>
                        <td>
                            @Html.ActionLink("Edit", "EditItem", new { codiitem = item.itemname.CodeItem }, new { @class = "btn btn-warning" }) |
                            @Html.ActionLink("Delete", "Delete", new { }, new { @class = "btn btn-danger" })
                        </td>
                    </tr>

                }
            </tbody>
        </table>
    </div>
</div>

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,272 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,277 questions
{count} votes

Accepted answer
  1. Karen Payne MVP 35,191 Reputation points
    2023-03-15T15:36:42.41+00:00

    First off not working is vague. Best recommendation is to ensure you have logging configured if this happens to be Entity Framework Core and review the code generated by EF Core, if not EF Core set a breakpoint and examine the query.

    0 comments No comments

0 additional answers

Sort by: Most helpful