IQueryable<TPT_ECN_MSTR> q = db.TPT_ECN_MSTRS.AsNoTracking();
if (_OrdDateFr == DateTime.MinValue && _OrdDateTo == DateTime.MaxValue) return q.Where(p => 1 == 2).ToList();
string usr_user = GetIdentityName();
OracleParameter[] pars = {
new OracleParameter("var_DateFr", OracleDbType.Date),
new OracleParameter("var_DateTo", OracleDbType.Date),
new OracleParameter("var_Vend", OracleDbType.Varchar2),
new OracleParameter("var_ecn_status", OracleDbType.Varchar2),
new OracleParameter("var_part", OracleDbType.Varchar2),
new OracleParameter("var_part_type", OracleDbType.Varchar2),
new OracleParameter("var_po", OracleDbType.Varchar2),
new OracleParameter("var_user", OracleDbType.Varchar2)
};
pars[0].Value = _OrdDateFr;
pars[1].Value = _OrdDateTo;
pars[2].Value = _vend;
pars[3].Value = _ecn_status;
pars[4].Value = _part;
pars[5].Value = _part_type;
pars[6].Value = _po;
pars[7].Value = usr_user;
var cmd = db.Database.Connection.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GET_ECN_REPORT";
if (pars.Length > 0)
cmd.Parameters.AddRange(pars);
// cmd.Parameters.AddRange(Oparms);
cmd.Connection.Open();
int retCode = cmd.ExecuteNonQuery();
cmd.Connection.Close();
q = q.Where(p => p.TPT_ECN_USER == usr_user);
// 在查询之后,排序和分页之前获取总记录数
pagingInfo.RecordCount = q.Count();
if (pagingInfo.RecordCount > 0 && string.IsNullOrWhiteSpace(pagingInfo.SortField))
{
pagingInfo.SortField = "ECN_VEND";
pagingInfo.SortDirection = "ASC";
}
// 排列和数据库分页
q = SortAndPage<TPT_ECN_MSTR>(q, pagingInfo);
return q.ToList();
原文地址:https://www.cnblogs.com/su1643/p/10364526.html