我有这个运算符页面,它有两个表来自数据库,一个表有现有运算符,一个表有现有用户。如果用户已经是操作员,我希望该行隐藏在表中。这是我的代码:
C#:
var userDetailsList = new List<ContactPartial>();
TellusAPI.TellusUserDetails userDetails;
var operators = _administrationSystem.GetOperatorsInformation(userId); //DataSet
var getUser = webSearch.DoSearchForNameAndNumber(userId, txtSearchForOperator.Text, false, "", "", false, false, out userDetails); //Array
if (getUser == null)
{
userDetailsList.Add(new ContactPartial(userDetails));
rptAdd.DataSource = null;
}
else
{
userDetailsList = getUser.Select(x => new ContactPartial(x)).ToList();
var dv = new DataView(operators.Tables[0]);
foreach (var Operator in userDetailsList)
{
if (!userDetailsList.Contains(Operator)) continue;
dv.RowFilter = "ID = " + Operator.Id;
}
rptAdd.DataSource = userDetailsList; //Repeater
}
类别:
/// <summary>
/// Class for converting.
/// </summary>
public class ContactPartial
{
public long Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string CompanyName { get; set; }
public string Email { get; set; }
public ContactPartial(TellusUserDetails tud)
{
if (tud == null)
{
return;
}
Id = tud.UserID;
FirstName = tud.FirstName;
LastName = tud.LastName;
CompanyName = tud.Organisation.Description;
Email = tud.Email;
}
public ContactPartial(TellusSearchUserInfo tsi)
{
if (tsi == null)
{
return;
}
Id = tsi.ID;
FirstName = tsi.FirstName;
LastName = tsi.LastName;
CompanyName = tsi.CompanyName;
Email = tsi.Email;
}
}
所以我现在比较这两个并用ID过滤行,但它仍然读取所有行。
答案 0 :(得分:1)
git describe
我发现命名约定存在一些问题。您应该正确地通知什么是运算符以及什么是用户详细信息对象。不要混淆它们。
foreach (var Operator in userDetailsList) ******
{
if (!userDetailsList.Contains(Operator)) continue;
dv.RowFilter = "ID = " + Operator.Id;
}