locked
linq to EntityDataSource RRS feed

  • Question

  • User-1392077014 posted

    hello i have a EntityDataSource in my page

    how can i linq to that and get data from my EntityDataSource?

    Monday, December 19, 2011 1:17 PM

Answers

  • User3866881 posted

    itry it but take error

     LINQ to Entities only supports casting Entity Data Model primitive types.

    Hello:)

    This error means that your bound items——some of it isn't basic type like int,double,float……,ect……

    My suggestion is that you can remove “ var orders = e.Query.Cast<SalesOrderHeader>();” and just directly use LINQ-TO-SQL's syntax to get a query and do databinding。

    Best reguards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 21, 2011 8:47 PM

All replies

  • Monday, December 19, 2011 2:38 PM
  • User3866881 posted

    hello i have a EntityDataSource in my page

    how can i linq to that and get data from my EntityDataSource?

    To handle the event of QueryCreated of EntitySource,the sample from MSDN:

    protected void EntityDataSource1_QueryCreated(object sender, QueryCreatedEventArgs e)
    {
        var orders = e.Query.Cast<SalesOrderHeader>();
        e.Query = from order in orders
            where order.SalesOrderID < 43661
            select order; 
    }

    Tuesday, December 20, 2011 9:35 PM
  • User-1392077014 posted

    itry it but take error

     LINQ to Entities only supports casting Entity Data Model primitive types.

    Wednesday, December 21, 2011 11:19 AM
  • User3866881 posted

    itry it but take error

     LINQ to Entities only supports casting Entity Data Model primitive types.

    Hello:)

    This error means that your bound items——some of it isn't basic type like int,double,float……,ect……

    My suggestion is that you can remove “ var orders = e.Query.Cast<SalesOrderHeader>();” and just directly use LINQ-TO-SQL's syntax to get a query and do databinding。

    Best reguards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 21, 2011 8:47 PM