我正在考虑在今后数周内开始利用第一个框架开展一个项目。
我在以前建立的数据库中有三个表格。 https://i.stack.imgur.com/Ka47J.png“alt=“EDMX”/。
创建公司Notice记录时,必须将至少一个地点(从地点表)列入公司NoticeLocations表。
e.g.
**CompanyNotice**
ID CompanyID Date Heading Text .....
2 9 2011-11-21 10:17:29.573 Lorem Ipsum 1 1 1
**CompanyNoticeLocations**
CompanyNoticeLocationsID CompanyNoticeID LocationID
1 2 4
2 2 5
3 2 1
Main question: Can anyone please tell me if I can use the EF to create an Entity called: CompanyNoticesWithLocations that just returns:
- Heading
- Text
- List of LocationNames
www.un.org/Depts/DGACM/index_spanish.htm 我已尝试与LINQ一道这样做,而没有向实体制图提供多张表格,我无法做到:
using (var context = new ALEntities())
{
var query = from c in context.CompanyNotices.Include("Locations")
select new
{
c.CompanyNoticeHeading,
c.CompanyNoticeText,
(from l in c.CompanyNoticesLocations select l.Location.LocationName)
};
ASPxGridView1.DataSource = query;
ASPxGridView1.DataBind();
}
然而,我有了一个错误:
Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.