Sharepoint 以编程方式访问与列关联的外部列表

Sharepoint 以编程方式访问与列关联的外部列表,sharepoint,sharepoint-2013,bcs,Sharepoint,Sharepoint 2013,Bcs,嗨,我有两个外部列表“A”和“B”。在A中有一个相关列,用于查找B。 当我在浏览器中查看/编辑项目时,它会显示正确的值,如下图所示 但当我试图在代码中访问列表时,我可以访问所有列值,但关联的列值为空。 代码如下所示: items = listReports.GetItems(); System.Collections.Generic.List<ReportItem> r

嗨,我有两个外部列表“A”和“B”。在A中有一个相关列,用于查找B。 当我在浏览器中查看/编辑项目时,它会显示正确的值,如下图所示

但当我试图在代码中访问列表时,我可以访问所有列值,但关联的列值为空。 代码如下所示:

                            items = listReports.GetItems();

                            System.Collections.Generic.List<ReportItem> reportItems = new List<ReportItem>();
                            foreach (SPListItem it in items)
                            {
                                if (it != null)
                                {

                                    ReportItem item = new ReportItem();
                // extItem comes null
                var extItem = it["ExtCol"];
                // extItem comes null

                  DateTime date;
                                    if (DateTime.TryParse(it["GeneratedOn"].ToString(), out date))
                                    {
                                        item.dateGenerated = date.Date;
                                    }

                                    DateTime time;
                                    if (DateTime.TryParse(it["GeneratedOn"].ToString(), out time))
                                    {
                                        item.timeGenerated = time.Date;
                                    }

                                    reportItems.Add(item);

                                }


                            }
items=listReports.GetItems();
System.Collections.Generic.List reportItems=新列表();
foreach(在项目中列出)
{
如果(it!=null)
{
ReportItem item=新的ReportItem();
//extItem为空
var extItem=it[“ExtCol”];
//extItem为空
日期时间日期;
if(DateTime.TryParse(it[“GeneratedOn”].ToString(),out date))
{
item.dateGenerated=日期.date;
}
日期时间;
if(DateTime.TryParse(it[“GeneratedOn”].ToString(),out time))
{
item.timeGenerated=时间.日期;
}
报告项目。添加(项目);
}
}
我不确定,但是,“ExtCol”-是外部类型中字段的正确名称吗?对于外部项,sharepoint可以在源字段名称中替换外部项/列的名称