1. ADO.NET Data Services
Name Kavankumar Nileshkumar Solanki
Department MSc.IT Roll No. 03
Semester 2nd Subject Code PS02CINT23
Institute Name Shree P.M.Patel Institute of PG Studies and Research in Applied
Science
Managed By Anand People’s Medicare Society, Anand
Presentation Title
Signature :-
2. Objectives
• Overview of ADO.NET Data Services
• Exposing data sources
• Building clients
• Intercepting the server-side dispatch process
3. Data Services – Overview
• Provides new functionality
– CRUD access to data over RESTful web services
– Built-in URI-based query syntax
– Client-side libraries for .NET, AJAX and Silverlight
• Builds on top of WCF V3.5
• Status
– In VS 2008 Service Pack 1, Ships Summer 2008
– Current version is in Sp1 Beta 1 but has been
through various previews
4. RESTful?
• REpresentational State Transfer
– Server-side resources identified by a URI
– Access is over HTTP, verb tied to action
• GET to read the value of a resource
• POST to create a new resource
• PUT to update an existing resource
• DELETE to delete a resource
– Returned data is “plain” – XML or JSON
• Is this “the death of SOAP”?
5. Data? What Kind of Data?
• Provide a type with public properties which
are IQueryable<T>
– Some rules about how T has to be formed
– Remember the extension method AsQueryable()
• Only get write access if your type implements
IUpdatable
• Works well with generated code from;
– ADO.NET Entity Framework (ObjectContext)
– LINQ to SQL (DataContext*)
8. What if there was no DAL?
• Is the EDM our DAL?
• EF Entities? Are these our business objects?
• Data Transfer Objects (DTO’s)
• What if we wrote LINQ queries directly in our
business layer?
– Separation of Concerns?
• High cohesion?
• Loose Coupling?
10. Entity Framework as a DAL
• Pros
– Excellent Isolation from DB Schema
– Independence from RDBMS
– Object Services: Identity & Change Tracking
– Full query comprehension over CDM in business logic
• Cons
– Pre-.NET 4.0, “Object First” is not well support
scenario
– Pre-.NET 4.0, Entities are not very pure (not POCO)
– Can’t easily switch ORM
– Data validation support is limited.
11. Validation & Business Logic
public string Phone
{
get
{
return this._Phone;
}
set
{
this.OnPhoneChanging(value);
this.ReportPropertyChanging("Phone");
this._Phone =
DataClasses.StructuralObject.SetValidValue(value, true);
this.ReportPropertyChanged("Phone");
this.OnPhoneChanged();
}
}
12. public partial class Customer
{
partial void OnPhoneChanging(string value)
{
if (value.Length < 7)
MyCustomErrorHandler.SetError(this.EntityKey,
"Invalid Phone Number");
}
}
13. Entity Framework 4.0
• Development Approaches
– Model first development
– Testability
• Architectural Concerns
– Persistent Ignorance (e.g. POCO)
– Application Patterns (Repository and UnitOfWork patterns)
– N-Tier applications
• Improvements
– Customization of code generation
– Pluralization and singularization, lazy loading, SPs
– Customizing queries
– SQL generation readability & query improvements