Skip to Main Content
Programming Atlas
book

Programming Atlas

by Christian Wenz
September 2006
Intermediate to advanced content levelIntermediate to advanced
408 pages
10h 38m
English
O'Reilly Media, Inc.
Content preview from Programming Atlas

Creating a Custom Data Source

If you want the full power of data access at your disposal and do not want to stick to the data structure provided by the data source, you can implement your data source by yourself, as a server-side ASP.NET class. Since Atlas relies heavily on web services, you have to implement a DataService class. The associated class is implemented in the Microsoft.Web.Services namespace. Within the DataService class, you have to implement the default methods for a data object: they are listed in the enumeration System.ComponentModel.DataObjectMethodType and include the following:

  • Delete

  • Insert

  • Select

  • Update

Displaying Data from a Custom Data Source

For demonstration purposes, we will first implement a web service SELECT method, which retrieves data from—you guessed it—the Purchasing.Vendors table in the AdventureWorks database.

You can, as before, implement a method that returns the desired data. By using the [DataObjectMethod(DataObjectMethodType.Select)] attribute, you declare the specific method as the “select” method. The actual naming of the method is arbitrary. As data type, you can again return a custom type, as shown in Example 9-5.

Example 9-5. Returning a custom type

ListViewVendorsDataServiceCustomType.asmx, excerpt
[DataObjectMethod(DataObjectMethodType.Select)] public Vendor[] GetVendors() { SqlConnection conn = new SqlConnection( "server=(local)\\SQLEXPRESS; Integrated Security=true; Initial Catalog=AdventureWorks"); conn.Open(); SqlCommand comm ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Go Systems Programming

Go Systems Programming

Mihalis Tsoukalos

Publisher Resources

ISBN: 0596526725Supplemental ContentCatalog PageErrata