我已经在实体模型中添加了一个数据库视图。现在我正在尝试将ObjectSet
放入我的ObjectContext
中,以便在应用程序中访问该视图。
对于常规表格,我的ObjectSet
看起来像这样:
private ObjectSet<StarVendor> _StarVendor;
public ObjectSet<StarVendor> StarVendor
{
get
{
if ((_StarVendor == null))
{
_StarVendor = base.CreateObjectSet<StarVendor>("Stratus_X_TestEntities.StarVendors");
}
return _StarVendor;
}
}
所以我也对我的视图做了同样的操作:
private ObjectSet<CatalogItemSearch> _CatalogItemSearch;
public ObjectSet<CatalogItemSearch> CatalogItemSearch
{
get
{
if ((_CatalogItemSearch == null))
{
_CatalogItemSearch = base.CreateObjectSet<CatalogItemSearch>("Stratus_X_TestEntities.CatalogItemSearch");
}
return _CatalogItemSearch;
}
}
但是当代码运行时,我遇到了一个异常:
我知道对于视图,我不需要System.InvalidOperationException "无法找到 EntitySet 名称 'Stratus_X_TestEntities.CatalogItemSearch'"
ObjectSet
提供的添加/更新/删除功能。是否有其他的集合类型适用于此?
或者这个错误与其是视图无关的东西有关?
谢谢。