none
ADO.NET Entity Framework - EntityDataSource and data transformation... + ASP.NET RRS feed

  • Question

  • Hi all,

    Alright so I'm working with an EDM model in ASP.NET and trying to use the EntityDataSource with a GridView...first of all I have to say that just to perform a simple select on the EntityDataSource I have to use this special "it" syntax and I'm going back to using a string - I thought the whole point of these data service frameworks was to make everything type-safe/strongly-typed! I might as well just go back to writing SQL statements; frankly I'm a little puzzled by this - if someone can recommend a better way to use an ASP.NET Entity Framework model with a GridView that will allow me to sort, order by and filter, please let me know...because right now even the LinqDataSource seemed a lot better - at least I could transform data using .NET using the Selecting event...

    That's the first question...the second: If I do continue to use the EntityDataSource to access my data model, how can I transform the data? I know I can use different SQL functions in my EntityDataSource.Select statement but one of the things I loved so much about LinqToSql was that I could do something like this:

    var peopleUpperCaseNames = from person in tblPeople select new { PersonName = person.PersonName.ToUpper() };

    Now that's a simple example but what if I wanted to use .NET to convert my date to a short date string, I would have done something like this:

    var someDates = from appointment in Schedule select new {AppointmentShortDate = appointment.Date.ToShortDateString() };

    Now what would be the preferred way to do these things using ADO.NET Entity Framework and an EntityDataSource?? It seems like I have to revert back to using SQL to perform these tasks via the EntityDataSource.Select string/statement which almost seems to completely defeat the purpose of this whole Object-Relational-Model thing (maybe a little exaggerated but you know what I mean) if I have to jerry-rig it to do something like that...someone help...please

    Much appreciated!!

    -Azad 


    ▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫
    Azad Ratzki Aka Taicho==
    http://azad.fucius.cc===
    ▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫
    • Moved by Matt Neerincx [MSFT] Sunday, May 3, 2009 11:38 PM EDM question (From:ADO.NET Data Providers)
    Friday, May 1, 2009 5:24 PM

Answers

  • Hello Azad,

    Let me clarify a few points about EntityDataSource:

    Queries in EntityDataSource are almost completely based on Entity SQL query builder methods. You can learn more about them at http://msdn.microsoft.com/en-us/library/bb896238.aspx. Query builder methods use "it" is a convention to enable arbitrary composition of queries using Entity SQL.

    Entity SQL is a textual query language based on SQL and therefore was not designed to have type safety verified by a compiler. Also, yes, I understand that the syntax looks more like SQL than as C# or VB query comprehension syntax.

    EntityDataSource was not designed to support the use of LINQ in the definition of queries in .NET 3.5 SP1 but we are working on enabling this on the next version. We are still not sure where this feature will land, but i can tell you in advance that we don't have plans for the EntityDataSource to support the "pseudo-LINQ" textual language currently supported by the LinqDataSource.

    If you want to use LINQ to Entities in ASP.NET you will probably need to base the solution on ObjectDataSource or somehow perform updates manually rather than using ASP.NET 2-way databinding. There is also the option of using ASP.NET MVC framework, although I understand that may imply learning a completely new way of developing in ASP.NET.

    Hope this answers your questions,
    Diego
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, May 5, 2009 5:38 AM
    Moderator

All replies

  • Hello Azad,

    Let me clarify a few points about EntityDataSource:

    Queries in EntityDataSource are almost completely based on Entity SQL query builder methods. You can learn more about them at http://msdn.microsoft.com/en-us/library/bb896238.aspx. Query builder methods use "it" is a convention to enable arbitrary composition of queries using Entity SQL.

    Entity SQL is a textual query language based on SQL and therefore was not designed to have type safety verified by a compiler. Also, yes, I understand that the syntax looks more like SQL than as C# or VB query comprehension syntax.

    EntityDataSource was not designed to support the use of LINQ in the definition of queries in .NET 3.5 SP1 but we are working on enabling this on the next version. We are still not sure where this feature will land, but i can tell you in advance that we don't have plans for the EntityDataSource to support the "pseudo-LINQ" textual language currently supported by the LinqDataSource.

    If you want to use LINQ to Entities in ASP.NET you will probably need to base the solution on ObjectDataSource or somehow perform updates manually rather than using ASP.NET 2-way databinding. There is also the option of using ASP.NET MVC framework, although I understand that may imply learning a completely new way of developing in ASP.NET.

    Hope this answers your questions,
    Diego
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, May 5, 2009 5:38 AM
    Moderator
  • Thanks a lot for the reply Diego, it definitely clears some things up. :-) While I have your attention maybe I can get you to answer another question that I am having trouble getting a straight answer about - once I have imported a stored procedure as a function (which has been mapped to an entity set based off one of my SQL views) how do I use it w/ the EntityDataSource, or do I have to use the ObjectDataSource as well?

    Thank you for your time,
                                        Azad
    ▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫
    Azad Ratzki
    http://azad.fucius.cc===
    ▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫
    Wednesday, May 6, 2009 10:01 PM