locked
How do i convert this multiple where cause SQL to eSQL?? RRS feed

  • Question

  • User-2129951835 posted

    T-SQL

     

    USE [AdventureWorks];
    SELECT p.* FROM Production.ProductCategory cat ,[Production].[ProductSubcategory] sub, [Production].[Product] p
    WHERE cat.ProductCategoryID=1 AND sub.ProductCategoryID = cat.ProductCategoryID and p.ProductSubcategoryID = sub.ProductSubcategoryID
    

     

    And i want to convert to eSQL for EntityDatasource

    <asp:EntityDataSource ID="ProductDataSource" runat="server"  ConnectionString="name=AdventureWorksEntities" 
        DefaultContainerName="AdventureWorksEntities"  EntitySetName="Product" 
        Where="EXISTS(SELECT VALUE cat FROM ProductCategory AS cat WHERE cat.ProductCategoryID=1) 
                 AND EXISTS(SELECT VALUE sub FROM ProductSubcategory AS sub WHERE sub.ProductCategoryID = cat.ProductCategoryID) 
                 AND it.ProductSubcategoryID = sub.ProductSubcategoryID) " 
        >
    </asp:EntityDataSource>

     

    But it is error.

     

    Thursday, March 10, 2011 9:28 PM

Answers

  • User-2129951835 posted

    It seem no one to answer...

    But i find the solution:

     

    string query = @"SELECT VALUE p FROM EntityContainer.ProductCategory cat, EntityContainer.ProductSubcategory sub, EntityContainer.Product p WHERE cat.ProductCategoryID=1 AND sub.ProductCategoryID = cat.ProductCategoryID and p.ProductSubcategoryID = sub.ProductSubcategoryID";
    EntityDataSource source = null; 
    source = Page.FindControl("ProductDataSource") as EntityDataSource;
    if(source != null) {
      source.EntitySetName = null;
      source.CommandText = query;
    }  
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 12, 2011 10:08 AM