0

I have an entity datasource and i would like to filter it (created_on) to show only the max date. How do i go about doing it?

<asp:EntityDataSource ID="Payroll_DetailsDS" runat="server" 
                ConnectionString="name=sspEntities" DefaultContainerName="sspEntities" 
                EnableDelete="True" EnableFlattening="False" EnableInsert="True" 
                EnableUpdate="True" EntitySetName="Payroll_Details" 
                OrderBy="it.[Payslip_no] desc" EntityTypeFilter="" Select="" 
                Where="it.Status = &quot;COM&quot;">
 </asp:EntityDataSource>

Right now the data source is only filtering by it.status. I would to filter also by it.created_on = Max(created_On) .. thats the idea of what i want, dont know how to get it.

i was able to get something similar in linq and it worked fine. just need it in entity datasource.

var testquery = from d in context.Payroll_Details
                                        where d.Created_on == ((from b in                                      context.Payroll_Details
                                        where b.Employee_Personal_InfoEmp_id == xyz.PD_EmpPersonal_Id
                                        select b.Created_on).Max())
                                        select new
                                        {
                                            d.Employee_Personal_InfoEmp_id,
                                            d.Basic_Pay_YTD
                                        };
                        var r = testquery.SingleOrDefault();
Eugene Pavlov
  • 688
  • 5
  • 18
Dineshp
  • 31
  • 1
  • 11

1 Answers1

0

If I undertand you right, you can use this way:

<asp:EntityDataSource ID="SalesOrderHeader" runat="server" 
  ConnectionString="name=AdventureWorksEntities" 
  DefaultContainerName="AdventureWorksEntities" EnableDelete="True" 
  EnableInsert="True" EnableUpdate="True" EntitySetName="SalesOrderHeader" 
  EntityTypeFilter="" OrderBy="it.TotalDue DESC" Select="" 
   Where="it.OnlineOrderFlag = TRUE AND it.TotalDue &gt; @ordercost">
  <WhereParameters>
    <asp:ControlParameter ControlID="costLimit" DbType="Int32" 
      DefaultValue="2500" Name="ordercost" PropertyName="Text" />
  </WhereParameters>
</asp:EntityDataSource>

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.entitydatasource.orderby.aspx

Elek Guidolin
  • 487
  • 1
  • 8
  • 21
  • What does this have to do with my question? – Dineshp Apr 02 '13 at 15:33
  • As I Told, if I understanded your question, you can OrderBy adding a Property to your EntityDataSource. You said that you did with Linq, but want to do in EntityDataSource, right ? – Elek Guidolin Apr 02 '13 at 17:19