public List<Email> GetEmailAccountDetailByIDWithSorting(
long EmailFolderID,
string subject,
string date,
string sortColumn,
string sortOrder,
int pageSize,
int pageIndex,
out int totalRecords)
{
var Emails = db.Emails
.Where(E => E.Subject.Contains(subject) &&
Convert.ToDateTime(E.Date).ToShortDateString() == date &&
E.EmailFolderId == EmailFolderID)
.OrderBy(u => u.Subject)
.ThenBy(u => u.Subject);
switch (sortColumn)
{
case "Subject":
Emails = (sortOrder == "desc") ? Emails.OrderByDescending(u => u.Subject) : Emails.OrderBy(u => u.Subject);
break;
case "Date":
Emails = (sortOrder == "desc") ? Emails.OrderByDescending(u => u.Date) : Emails.OrderBy(u => u.Date);
break;
default:
break;
}
totalRecords = Emails.Count();
return Emails.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
}
私のlinqクエリ文字列の入力日付は「2013-07-15」で、E.Date
データベースの日付を入力日付形式に変換する方法です。このクエリデータベースの日付では、「2013-07-15 11:35:48.000」のようになります