在 MVC4 中需要列出一组客户端。我通过创建 2 个模型 ClientList 和 Client 模型来实现这一点。我将 ClientList 类设置为可序列化的。现在需要为这个模型应用各种参数的过滤条件。如何做到这一点?这是我的模型。
public class Client : Paging
{
public virtual string CompanyName { get; set; }
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
}
[Serializable]
public class ClientList : Paging
{
private Client _client;
public Client Client
{
get { return _client; }
set { _client = value; }
}
}
在数据访问中,我正在使用这个
while (reader.Read())
{
var rCompanyName = reader.GetOrdinal("CompanyName");
var rFirstName = reader.GetOrdinal("FirstName");
var rLastName = reader.GetOrdinal("LastName");
var resultClientList = new Client
{
CompanyName = Convert.IsDBNull(rCompanyName) ? string.Empty : reader.GetString(rCompanyName),
FirstName = Convert.IsDBNull(rFirstName) ? string.Empty : reader.GetString(rFirstName),
LastName = Convert.IsDBNull(rLastName) ? string.Empty : reader.GetString(rLastName)
};
var clients = new ClientList();
admin.Client = resultClientList;
result.Data.Add(clients);
}
鉴于,
@model IEnumerable<Midlab.FreightOnce.BusinessObjects.ClientList
@*i need filter condition here*@
@foreach (var item in Model)
{
--rendering list here
}
谢谢