gpt4 book ai didi

c# - 将其显示到 "Table1"表中

转载 作者:可可西里 更新时间:2023-11-01 08:27:04 25 4
gpt4 key购买 nike

下面是上面提到的方法:

public IList<tst> testUsers()
{
IList<tst> testUsers = _test.GetAll().ToList();
return test(test);
}

最佳答案

要显示带有位置的用户,我认为您需要一个名为 AdsnapshotUsers 的类

public class AdsnapshotUsers
{
// three fields UserId, UserLogonName, Location

}

现在创建一个返回 IList<AdsnapshotUsers> 的方法

 public IList<AdsnapshotUsers> GetAdsnapshotUsers()
{
List<User> Users = GetAcitveUsers().ToList();
List<ADSnapshot> adSnapshotUsers = _adSnapshotRepository.GetAll().ToList();

return (from u in Users
join ad in adSnapshotUsers on u.UserLogonName equals ad.UserLogonName
select new AdsnapshotUsers {
UserId= u.UserId, UserLogonName = u.UserLogonName, Location = ad.Location
}
).ToList<AdsnapshotUsers>();
}

Left Outer Join 显示用户表中的所有值,即使 adsnapshot 表中不存在用户登录名(位置值空白)

 (from u in Users 
join ad in adSnapshotUsers on u.UserLogonName equals ad.UserLogonName into aduserselect
from ad1 in aduserselect.DefaultIfEmpty()
select new AdsnapshotUsers {
UserId= u.UserId, UserLogonName = u.UserLogonName, Location = ad1.Location
}
).ToList<AdsnapshotUsers>();

此处将选择用户表中的所有记录,如果 userlogonname 存在,则位置名称值设置为 ADSnapshot 表值,否则不存在,则设置默认空值。

关于c# - 将其显示到 "Table1"表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12404592/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com