1

こんにちは、EntityDataSource を使用してアイテムを取得しています。特定の地域のアイテムを取得したいと考えています。(項目と地域には多対多の関係があるため、項目には地域ナビゲーション プロパティがあります)。「IN」を使用してアイテムをフィルタリングしています。いくつかの組み合わせを試してみましたが、さまざまなエラーが発生し続けました。どうすればこれを整理できますか:

以下は私のデータソースです:

<asp:EntityDataSource ID="CataloguesDataSource" runat="server" ConnectionString="name=ModelContainer" 
    DefaultContainerName="ModelContainer" EnableInsert="false" EnableUpdate="false"  OrderBy="it.EndDate desc,it.id desc" Include="it.Regions"
    EntitySetName="Catalogues"   Select="it.Id,it.Name,it.StartDate,it.EndDate,it.RetailerId"
    Where="it.Retailer.Name=@RetailerName and @Region IN (select p.Id from it.Regions as p)" >
   <WhereParameters> 
        <asp:ControlParameter Name="RetailerName" ControlID="hdnRetailer" DbType="String"  PropertyName="Value" DefaultValue="abc"  />
        <asp:ControlParameter Name="Region" ControlID="hdnregion" DbType="Int32"  PropertyName="Value" DefaultValue=""  />      

     </WhereParameters>
</asp:EntityDataSource>  
4

1 に答える 1

-1

通常、 in キーワードは次のように使用します。

これは MVC 3 であり、これは Entity フレームワークを使用するコントローラーにあります。


public ActionResult Index()
        {
            myEntities context = new myEntities();

            var result = from o in context.entitya
                         where o.somecolumn != "blahh"
                         select new
                         {
                             id = o.id,
                             name = o.name
                         };

            return Json(new { data = result, total = result.count() }, JsonRequestBehavior.AllowGet);
        }
于 2011-03-05T21:52:42.060 に答える