我有这个运算符页面,它有两个表来自数据库,一个表有现有运算符,一个表有现有用户。如果用户已经是操作员,我希望该行隐藏在表中。这是我的代码:
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
{
var query = getUser.Where(y => y.ID == (long)operators.Tables[0].Rows[0]["ID"]).Select(x => x.ID);
var result = from o in operators.Tables[0].AsEnumerable()
where o.Field<int>("ID") == Convert.ToInt64(query)
select o;
rptAdd.DataSource = result;
}
类别:
/// <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过滤行,但它仍然读取所有行。为什么呢?