var user = db.t_ST_User .Where(_user => string.Compare(domain, _user.domainName, StringComparison.OrdinalIgnoreCase) == 0) .Where(_user => string.Compare(samAccountName, _user.samAccountName, StringComparison.OrdinalIgnoreCase) == 0) .Where(_user => _user.deleted == false) .FirstOrDefault();
上面的代码给我以下错误:
LINQ to Entities 不支持指定的类型成员“domainName”。仅支持初始值设定项、实体成员和实体导航属性。
但domainName
实体是 的成员t_ST_User
,不是吗?
代码在迁移到新计算机之前可以正常工作,不确定是否相关。
public static int GetUserId(string domainName)
{
int nonExistingUserId = 0;
try
{
string message = "";
using (var db = new SurfaceTreatment.SurfaceTreatmentEntities())
{
string domain = domainName.Split('\\')[0].Trim();
string samAccountName = domainName.Split('\\')[1].Trim();
var user = db.t_ST_User
.Where(_user => string.Compare(domain, _user.domainName, StringComparison.OrdinalIgnoreCase) == 0)
.Where(_user => string.Compare(samAccountName, _user.samAccountName, StringComparison.OrdinalIgnoreCase) == 0)
.Where(_user => _user.deleted == false)
.FirstOrDefault();
if (user == null)
{
message = "Failed to get user by domain name: " + domainName;
LogHandler.LogDebug(logger, message);
return nonExistingUserId;
}
else
{
return user.userId;
}
}
}
catch (Exception ex)
{
LogHandler.LogError(logger, ex);
return nonExistingUserId;
}
}
public partial class t_ST_User
{
public int userId { get; set; }
public string badgeNumber { get; set; }
public string domainName { get; set; }
public string samAccountName { get; set; }
public string userName { get; set; }
public string userRemark { get; set; }
public System.DateTime createDate { get; set; }
public int createBy { get; set; }
}
qq_遁去的一_1
相关分类