Typed Datasource Controls

Typed DataSource Controls

Intellisense:



Strongly Typed DataSource controls: You will find that just by typing
Intellisense:



When you select the SelectMethod Attribute, you will see via intellisense a list of all available methods from your domain. How cool is that!

WebForm:



Here's an example of a webform in it's minimilist form, that would display a grid of all Employees with Auto-Generated columns.

Design View: Taking the form and selecting only the columns that I want, we create a nice grid.

Here's the result of of the form. The wonderful part of the Typed DataSource control is that you don't have to do anything when you want to edit/insert/delete an object. You simply have the grid call the Edit/Delete/Insert command, which can be done a variety of ways in ASP.net 2.0.

Results: Edit: After Edit:



Include Directives: When you want to actually interact with the data, you simply have to include your the generated tiers as using directives. We recommend as much encapsulation as possible, with both your Service Objects and your Collection/Entity classes. From here's it's relatively intuitive to work with your sets using a TList as you would an IList.

Codebehind

Quick Start Sample API: Top AccountService accountsService = new AccountsService();//GetAll() TList accountList = accountsService.GetAll();

//GetPagedl() TList accountList = accountsService.GetPaged("IsActive = 1 AND AccountName LIKE 'smi%'");

//GetByFk() TList accountList = accountsService.GetByCustomerId(25);

//GetIX() TList accountList = accountsService.GetByAccountCreatedDate(new DateTime("1/1/2006")); //Get() entity.Entitykey; TList accountList = accountsService.Get(entity.EntityKey);

Account accountEntity = new Account();accountEntity.AccountName = "MyAccountName";accountEntity.CreatedDate = DateTime.Now;

//Insert() TList accountList = accountsService.Insert(accountEntity); //Delete() TList accountList = accountsService.Delete(accountEntity);

//Delete() TList accountList = accountsService.Delete(23);

//Update() accountEntity.AccountName = "MyAccountName 2"; TList accountList = accountsService.Update(accountEntity);

//GetByManyToManyl() TList accountList = accountsService.GetCustomers_From_AccountsReceivable();

//GetCustomProcedureName() TList accountList = accountsService.GetByAccountMaturationDate();

//DeepLoadByIdl() using PK Account account = accountsService.DeepLoadByAccountId(id, false, DeepLoadType.IncludeChildren, typeof(Customers), typeof(TList)); //DeepLoadByIdl() using FK TList account = accountsService.DeepLoadByCustomerId(id, false, DeepLoadType.IncludeChildren, typeof(Customers), typeof(TList)); //already instatiated objects //DeepLoad TList account = accountsService.DeepLoad(myAccountEntity, false, DeepLoadType.IncludeChildren, typeof(Customers), typeof(TList)); //DeepSave TList account = accountsService.DeepSave(myAccountEntity, false, DeepSaveType.IncludeChildren, typeof(Customers), typeof(TList));



Working with the Code:

You will quickly discover that while there is a slew code being generated, the concepts themselves are simple, and familiar concepts based on proven practices and patterns.

string custId = "TRAIH";

//I get a single instance of the customer I want. Customers customer = DataRepository.CustomersProvider.GetByCustomerID(custId);

Type[] typesToDeepLoad = new Type[] { typeof(TList), typeof(TList) };

//go further than one level down object graph bool goMoreThanOneLevelDeep = true;

// I'm going to deep load this customer, but I only want // to see his orders and the products that he's made, // I really don't care about the line items // But the neat thing is that the relationship to products is through // line items. /// the object graph looks somethign like this /// - Customer /// Order /// -OrderDetails /// -ProductCollection /// CustomerDemographics /// --CustomerDemographicsCollection_From_CustomerCustomerDemo /// (a strangely named northwind thing, but shows how many to many relationships work.)

DataRepository.CustomersProvider.DeepLoad( customer, // my customer goMoreThanOneLevelDeep, //go further than one level down object graph DeepLoadType.IncludeChildren, //be Inclusive, instead of exclusive typesToDeepLoad );