【发布时间】:2009-06-23 12:29:06
【问题描述】:
正确的有一些关于 Linq to SQL 和 MVC 的硬脑力博客。
让基本的 MVC 和 L2SQL 正常运行。
- FK 关系。 -> 当使用 MVC 并且我们在模型中有一个 fk 关系时, 并且视图基于强类型对象 - 如何从相关表中获取数据?
例如
User (Table)
UserId
UserName
Call (Table)
CallId
UserId
CountryId
Country(Table)
CountryID
CountryName
所以我只想接听特定国家/地区用户的电话?
视图 - 基于调用对象,因为这是“详细信息”视图 -
我如何获得 UserName 和 CountryName 并仍然保持基于 Call 的视图?
看来我仍然需要创建一个对象 CallForUserByCountry - 但这会变得一团糟 在保存为 CallForUserByCountry 对象时还需要实现如何创建呼叫用户和国家。
linq 查询
var calls = from c in db.Call
where c.CountryID == id
select new CallForUserByCountry or new something// this is bit that suggests a new object.
希望我错过了什么......
【问题讨论】: