2011-07-05 12 views
0

私は2つのエンティティを持っている:CmsGroupsTypesウィッヒは、Entity CmsContentsCmsContentsと呼ばれるナビゲーションプロパティがあります。Entity Frameworkの私は私のモデルではAsp.netとEF 4</p> <p>を使っ含めるとナビゲーションプロパティ

私はGridViewコントロールと一緒にEntityDataSourceコントロールを使用しています。

戻り値はCmsGroupsTypesですが、ナビゲートプロパティとQueryStringParameterを使用してテーマをフィルタリングする必要があります。

'ContentId' is not a member of 'Transient.collection[CmsModel.CmsContent(Nullable=True,DefaultValue=)]'. To extract a property of a collection element, use a subquery to iterate over the collection 

<asp:EntityDataSource ID="EntityDataSource1" runat="server" 
    ConnectionString="name=CmsConnectionStringEntityDataModel" DefaultContainerName="CmsConnectionStringEntityDataModel" 
    EnableFlattening="False" EntitySetName="CmsGroupsTypes" Include="it.CmsContents.ContentId" 
    Where="it.CmsContents.ContentId == ContentId"> 
    <WhereParameters> 
     <asp:QueryStringParameter Name="ContentId" QueryStringField="ContentId" DbType="Int32" /> 
    </WhereParameters> 
</asp:EntityDataSource> 

任意のアイデア私が間違ってやっている:次のコードで

私はエラーが発生しますか?

私は、LINQで同等のバージョンを持っているし、それが働いているが、私はEntityDataSourceコントロールにdirectily実装する必要があります。

 // Get ContentId from Query String. 
     int myContentId = Convert.ToInt32(ContentIdFromUrl); 
     // Find all GroupsType for a specific Content. 
     var myGroupsTypesList = from g in context.CmsGroupsTypes 
           where g.CmsContents.Any(x => x.ContentId == myContentId) 
           select g; 

答えて

0

クイック推測:Includeは、ナビゲーションプロパティの名前を取り、その代わりに:

Include="it.CmsContents.ContentId" 

それは

Include="it.CmsContents" 

すべきではありませんか?

関連する問題