locked
When do I use SqlDataSource vs EntityDataSource vs ObjectDataSource RRS feed

  • Question

  • User-387865122 posted

    I brand new using web developer express. How do I decide what datasource control to use?

    Monday, January 21, 2013 3:16 PM

Answers

  • User-1528094326 posted

    They all serve different purposes.

    SqlDataSource uses straight ADO.NET under the covers. That means it writes all the raw SQL connection data and commands for you and controls them on a page so you don't have to worry about them. If you are only using SQL and you don't care to manually control anything this is an ok choice.

    EntityDataSource is exactly what it says, it controls Entity objects using the LINQ to Entities technology. It represents an EDM (Entity Data Model) and will handle all the context calls and submissions for you essentially

    ObjectDataSource is a wrapper that will control any Object you want for CRUD operations. If you have a custom access object you wrote yourself and need it to do custom code then that's your choice for ease of access. This control is also used for other types of controls such as the ReportViewer. The ReportViewer has what's called ReportDataSources and they generally wrap ObjectDataSources under the covers.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 21, 2013 3:23 PM
  • User-1528094326 posted

    You only need the Entity framework if you are wanting to use the EntityDataSource

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 21, 2013 3:33 PM

All replies

  • User-1528094326 posted

    They all serve different purposes.

    SqlDataSource uses straight ADO.NET under the covers. That means it writes all the raw SQL connection data and commands for you and controls them on a page so you don't have to worry about them. If you are only using SQL and you don't care to manually control anything this is an ok choice.

    EntityDataSource is exactly what it says, it controls Entity objects using the LINQ to Entities technology. It represents an EDM (Entity Data Model) and will handle all the context calls and submissions for you essentially

    ObjectDataSource is a wrapper that will control any Object you want for CRUD operations. If you have a custom access object you wrote yourself and need it to do custom code then that's your choice for ease of access. This control is also used for other types of controls such as the ReportViewer. The ReportViewer has what's called ReportDataSources and they generally wrap ObjectDataSources under the covers.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 21, 2013 3:23 PM
  • User-387865122 posted

    Is the Entity Framework necessary for both?

    Monday, January 21, 2013 3:31 PM
  • User-1528094326 posted

    You only need the Entity framework if you are wanting to use the EntityDataSource

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 21, 2013 3:33 PM
  • User-387865122 posted

    Thanx.

    Monday, January 21, 2013 3:37 PM