我有這個頁面的運算符有兩個表,其中包含來自數據庫的數據,帶有現有運算符的一個表和帶有現有用戶的一個表。如果用戶已經是操作員,我希望該行在表格中隱藏。這裏是我的代碼:帶數據集的數據行篩選數組c#net淨
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過濾行,但它仍然讀取所有行。
你能提供一些示例數據和預期結果,並在你的代碼哪行做什麼和不做什麼,預計一些解釋? –
預期的結果是,當您搜索數據庫中的用戶時,您想要過濾掉已包含在操作員表中的那些用戶。我有應該知道的ID。 – Malphai
@ChetanRanpariya請閱讀評論。 – Malphai