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.
NineIron
Member
2 Points
32 Posts
When do I use SqlDataSource vs EntityDataSource vs ObjectDataSource
Jan 21, 2013 07:16 PM|LINK
I brand new using web developer express. How do I decide what datasource control to use?
N_EvilScott
Star
8179 Points
1466 Posts
Re: When do I use SqlDataSource vs EntityDataSource vs ObjectDataSource
Jan 21, 2013 07:23 PM|LINK
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.
NineIron
Member
2 Points
32 Posts
Re: When do I use SqlDataSource vs EntityDataSource vs ObjectDataSource
Jan 21, 2013 07:31 PM|LINK
Is the Entity Framework necessary for both?
N_EvilScott
Star
8179 Points
1466 Posts
Re: When do I use SqlDataSource vs EntityDataSource vs ObjectDataSource
Jan 21, 2013 07:33 PM|LINK
You only need the Entity framework if you are wanting to use the EntityDataSource
NineIron
Member
2 Points
32 Posts
Re: When do I use SqlDataSource vs EntityDataSource vs ObjectDataSource
Jan 21, 2013 07:37 PM|LINK
Thanx.