-1

private async Task RunningData() {

// i want to get data in between two dates in windows phone using azure storage.

        var table = MobileService.GetTable<Tracing>();
        string date1 = "13/09/2014 12:58:42";
        string date2 = "12/09/2014 16:26:55";
        var items = await table
            .Where(Tracing => Tracing.Date == date1 || Tracing.Date==date2 )               
            .Take(PageSize)
            .Skip(this.currentIndex)
            .IncludeTotalCount()
            .ToListAsync();


        this.lstItems.ItemsSource = items;
        int totalCount = (int)((ITotalCountProvider)items).TotalCount;
        this.lblStatus.Text = string.Format("Showing items from position {0} to {1} (of {2})", currentIndex, currentIndex + PageSize - 1, totalCount);
    }

1 Answers1

0

You can create an extension method (thanks to Equivalent of SQL Between Statement Using Linq or a Lambda expression):

public static bool IsBetween(this DateTime dt, DateTime start, DateTime end)
{
   return dt >= start && dt <= end;    
}

and then call it from your linq query:

var items = await table
        .Where(Tracing => Tracing.Date.IsBetween(date1, date2))               
        .Take(PageSize)
        .Skip(this.currentIndex)
        .IncludeTotalCount()
        .ToListAsync();
Community
  • 1
  • 1
Jonathan
  • 4,916
  • 2
  • 20
  • 37