Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Custom data access class - IDataAdapter.SelectCommand
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
00950319
Message ID:
00950893
Views:
15
>In that case you can simply override your business object's CreateDataSet() method so it always instantiates an instance of your typed DataSet. For example:
>protected override mmDataSet CreateDataSet()
>{
>	return new MyDataSet();
>}
Okay, I put that in my class. Then do I still put in the "GetVendors" method you demonstrated earlier in this thread:
public DataSet GetVendors()
{
    // Pass whatever parameters you need here, or call FillDataSet 
    // if you have an existing ds you want to fill
    return this.GetDataSet(); 
}
I tried adding your version of GetVendors to my class, but it doesn't compile, because none of the overloads for GetDataSet take zero parameters, which is the way you've got the method coded.

I thought I had to use FillDataSet in order to work with typed datasets. Are you saying that if I only ever needed the default IDataAdapter.SelectCommand, that I could use a typed dataset and NEVER use FillDataSet?

Here's my whole Vendor.cs class. Please let me know if I'm on the right track:
using System;
using System.Data;

using OakLeaf.MM.Main.Business;
using OakLeaf.MM.Main.Data;

namespace MyCo.WarehouseSystem.Business
{
	public class Vendor : ABusinessObject
	{
		public Vendor()
		{
			this.TableName = "Vendor";
			this.PrimaryKey = "VendorNo";
			this.RetrieveAutoIncrementPK = false;
		}

		protected override mmDataAccessBase CreateDataAccessObject(string dataAccessClassName)
		{
			return new VendorDataAccessSql();
		}

		protected override mmDataSet CreateDataSet()
		{
			return new VendorDataSet();
		}

		public override DataSet GetEmptyDataSet()
		{
			return new VendorDataSet();
		}

		public DataSet GetVendors()
		{
			return this.GetDataSet();
		}

		protected override mmBusinessRule CreateBusinessRuleObject()
		{
			return new VendorRules(this);
		}

		protected override void HookSetDefaultValues(DataRow dataRow)
		{
			dataRow["Address"] = String.Empty;
			dataRow["Address2"] = String.Empty;
			dataRow["City"] = String.Empty;
			dataRow["State"] = String.Empty;
			dataRow["ZipCode"] = String.Empty;
			dataRow["Phone"] = String.Empty;
			dataRow["Fax"] = String.Empty;
		}

		protected override bool HookPreSave(DataTable dt)
		{
			foreach(DataRow dr in dt.Rows)
			{
				dr["VendorNo"] = dr["VendorNo"].ToString().Trim().ToUpper();
			}
			return true;
		}

	}
}
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform