0
我一直在做这么多的发布和获取单个记录很长时间,现在我有点失去了为什么我的模型不能从我的linq查询轻松水合。Linq查询返回作为模型列表
型号:
public class v_TRegister_Email
{
public string Email { get; set; }
public string LastFirst { get; set; }
public string FIRST_NAME { get; set; }
public string INITIALS { get; set; }
public string LAST_NAME { get; set; }
public string ALIAS_NAME { get; set; }
[Key]
public string EMPLOYEE_NUMBER { get; set; }
}
用于检索数据
//List of Model
List<v_TRegister_Email> tRegisterEmails = new List<v_TRegister_Email>();
// trying to make "query" contain the list<T>
var query = (from s in _db.VtRegisterEmails
where s.Email.Contains(id) // .Where(n => n.Email == id)
select new
{
// ??? x = s.Email
})
.ToList();
我通常滋润单记录与foreach循环
foreach (var q in query)
{
tRegisterEmails.// .Email = q.Email;
}
我缺少什么方法?
UPDATE
我想这也许是我已经数据从数据库相匹配的模型
var query = (from s in _db.VtRegisterEmails
where s.Email.Contains(id) // .Where(n => n.Email == id)
select s).ToList();
然而,即使是这样的话,就没有我有时候可能想循环查询,并可能映射到我喜欢的字段?
我该怎么做?
雅, - 所以_db.VtRegisterEmails已经是我的模型...我过度思考,过度工作冲激谢谢 –
大声笑 - 甜,很高兴你回到正轨! – code4life