Linq to SQL 添加了一个 Lambda .Join getting AnonymousType#1' does not contain a definition and no extension method
Linq to SQL added a Lambda .Join geting AnonymousType#1' does not contain a definition and no extension method
加入 Lambda 时加入。加入我的 linq lambda 出现问题 .Where(..
.Where(z => z.Inact_ind == "N" && z.Wwid != null)
很好,直到我在上面添加 .Join
。
例如
.Join(Rpm_scrty_emp_info, z => z.Wwid, ei => ei.Wwid, (z, ei) => new{z,ei})
linq 查询
(Linqpad , 所以 Rpm_scrty_rpm_usrs 本质上与 dbcontext dbset 相同)
var queryAllUsers = Rpm_scrty_rpm_usrs
.Join(Rpm_scrty_emp_info, z => z.Wwid, ei => ei.Wwid, (z, ei) => new{z,ei})
.Where(z => z.Inact_ind == "N" && z.Wwid != null)
.AsEnumerable()
.Select(z => new rpm_scrty_rpm_usr()
{
usr_id = z.Usr_id,
usr_lnm = z.Usr_lnm,
usr_pwd = z.Usr_pwd,
usr_fnm = z.Usr_fnm,
wwid = z.Wwid,
apprvr_wwid = z.Apprvr_wwid,
chg_dtm = z.Chg_dtm,
chg_usr_id = z.Chg_usr_id,
dflt_ste_id = z.Dflt_ste_id,
cre_dtm = z.Cre_dtm,
cre_usr_id = z.Cre_usr_id,
lst_pwd_chg_dtm = z.Lst_pwd_chg_dtm,
lst_accs_dtm = z.Lst_accs_dtm,
email_id = z.Email_id,
inact_ind = z.Inact_ind,
salt = z.Salt,
tel = z.Tel
//});
})
.ToList();
波科class
public class rpm_scrty_rpm_usr
{
public string usr_id { get; set; }
public string usr_fnm { get; set; }
public string usr_lnm { get; set; }
public string usr_pwd { get; set; }
public string email_id { get; set; }
public string wwid { get; set; }
public string tel { get; set; }
public int dflt_ste_id { get; set; }
public DateTime? lst_pwd_chg_dtm { get; set; }
public DateTime? lst_accs_dtm { get; set; }
public string apprvr_wwid { get; set; }
public string inact_ind { get; set; }
public string cre_usr_id { get; set; }
public DateTime? cre_dtm { get; set; }
public string chg_usr_id { get; set; }
public DateTime? chg_dtm { get; set; }
public string salt { get; set; }
}
当你return:
.Join(Rpm_scrty_emp_info, z => z.Wwid, ei => ei.Wwid, (z, ei) => new{z,ei})
您实质上是在为您尝试加入的每个数据源创建一个新的匿名类型,该类型具有 属性。我怀疑您只是想 return z 对象。尝试:
.Join(Rpm_scrty_emp_info, z => z.Wwid, ei => ei.Wwid, (z, ei) => z)
returned 对象应该是类型 z,这意味着您可以在 .Where() 子句中访问它的属性(因为它是强类型的)。
联接后,联接查询中的每个条目都有两个 rpm_scrty_rpm_usr
,一个名为 z
,另一个名为 ei
。
你需要明确where语句:你要过滤哪一个,例如:
.Where(z => z.z.Inact_ind == "N" && z.z.Wwid != null)
加入 Lambda 时加入。加入我的 linq lambda 出现问题 .Where(..
.Where(z => z.Inact_ind == "N" && z.Wwid != null)
很好,直到我在上面添加 .Join
。
例如
.Join(Rpm_scrty_emp_info, z => z.Wwid, ei => ei.Wwid, (z, ei) => new{z,ei})
linq 查询
(Linqpad , 所以 Rpm_scrty_rpm_usrs 本质上与 dbcontext dbset 相同)
var queryAllUsers = Rpm_scrty_rpm_usrs
.Join(Rpm_scrty_emp_info, z => z.Wwid, ei => ei.Wwid, (z, ei) => new{z,ei})
.Where(z => z.Inact_ind == "N" && z.Wwid != null)
.AsEnumerable()
.Select(z => new rpm_scrty_rpm_usr()
{
usr_id = z.Usr_id,
usr_lnm = z.Usr_lnm,
usr_pwd = z.Usr_pwd,
usr_fnm = z.Usr_fnm,
wwid = z.Wwid,
apprvr_wwid = z.Apprvr_wwid,
chg_dtm = z.Chg_dtm,
chg_usr_id = z.Chg_usr_id,
dflt_ste_id = z.Dflt_ste_id,
cre_dtm = z.Cre_dtm,
cre_usr_id = z.Cre_usr_id,
lst_pwd_chg_dtm = z.Lst_pwd_chg_dtm,
lst_accs_dtm = z.Lst_accs_dtm,
email_id = z.Email_id,
inact_ind = z.Inact_ind,
salt = z.Salt,
tel = z.Tel
//});
})
.ToList();
波科class
public class rpm_scrty_rpm_usr
{
public string usr_id { get; set; }
public string usr_fnm { get; set; }
public string usr_lnm { get; set; }
public string usr_pwd { get; set; }
public string email_id { get; set; }
public string wwid { get; set; }
public string tel { get; set; }
public int dflt_ste_id { get; set; }
public DateTime? lst_pwd_chg_dtm { get; set; }
public DateTime? lst_accs_dtm { get; set; }
public string apprvr_wwid { get; set; }
public string inact_ind { get; set; }
public string cre_usr_id { get; set; }
public DateTime? cre_dtm { get; set; }
public string chg_usr_id { get; set; }
public DateTime? chg_dtm { get; set; }
public string salt { get; set; }
}
当你return:
.Join(Rpm_scrty_emp_info, z => z.Wwid, ei => ei.Wwid, (z, ei) => new{z,ei})
您实质上是在为您尝试加入的每个数据源创建一个新的匿名类型,该类型具有 属性。我怀疑您只是想 return z 对象。尝试:
.Join(Rpm_scrty_emp_info, z => z.Wwid, ei => ei.Wwid, (z, ei) => z)
returned 对象应该是类型 z,这意味着您可以在 .Where() 子句中访问它的属性(因为它是强类型的)。
联接后,联接查询中的每个条目都有两个 rpm_scrty_rpm_usr
,一个名为 z
,另一个名为 ei
。
你需要明确where语句:你要过滤哪一个,例如:
.Where(z => z.z.Inact_ind == "N" && z.z.Wwid != null)