Code Samples
Here you will find some code samples that will help you get started using the code generated by Orasis Mapping Studio.Call data access methods that were generated by your mapping project.
For example, assume you have a mapping project with class CustomerInfoDataAccess for accessing Customer information from the database.
//Instantiate your data access class
private CustomerInfoDataAccess customerInfoAccess = new CustomerInfoDataAccess();
//Call the method to expose the data of interest
System.Collections.Generics.IList<CustomerDetail> customerDetails = customerInfoAccess.GetCustomerDetails();
//You now have a collection of model objects that have been injected with data from the database!
You can easily build your data access layer with the Orasis Mapping Studio IDE and then expose your data through Web Services.
For example, assume you have a mapping project with class ReportingDataAccess for accessing information for reports from the database.
//
// Summary description for the web service
//
[WebService(Namespace = "http://orasissoftware.com/ReportingService/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class ReportingService : System.Web.Services.WebService
{
private ReportingDataAccess dataAccessManager;
public ReportingService()
{
//Instantiate your data access class
dataAccessManager = new ReportingDataAccess();
}
[WebMethod]
public InventoryReportDetail[] GetInventoryReportDetail(DateTime beginDate, DateTime endDate)
{
//Call your data access method
List<InventoryReportDetail> rs = (List<InventoryReportDetail>)dataAccessManager.GetInventoryReportDetail(beginDate, endDate);
return rs.ToArray();
}
[WebMethod]
public List<ProductModel> GetProductInfo(decimal productId)
{
return (List<ProductModel>)dataAccessManager.GetProductInfo(productId);
}
}
Simply bind your collection of model objects to the DataGridView control. The actual data access code is abstracted through code that is generated with the IDE.
For example, assume you have a mapping project with class ReportingDataAccess for accessing information for reports from the database.
//method for initializing inventory report data that is bound to a DataGridViewControl
private void InitializeInventoryReport()
{
try{
Cursor = Cursors.WaitCursor;
IList<InventoryReportDetail> detail = dataAccessManager.GetInventoryReportDetails("en");
SetHeaderData("Inventory Report", detail.Count);
reportDataGridView.DataSource = detail;
}
finally
{
Cursor = Cursors.Default;
}
}