Quantcast
Viewing all articles
Browse latest Browse all 764

Another Beginner Easy Question

I'm trying to do something really basic.  I have a lookup table called TWageType and the structure is simply a description field containing 3 records (Hourly, Salary, Other).

I'm trying to create my first business object to simply allow me to retrieve all the records and bind them to a grid for admin maintenance.

So I have a WageType class inheriting from BusinessBase<WageType> and I have a WageTypes collection inheriting from BusinessBindingListBase<WageTypes,WageType>.  All works so far.

I have the following method in the WageTypes collection (list):

        public static async Task<WageTypes> GetAll()
        {
            return await DataPortal.FetchAsync<WageTypes>();
        }

and in the DataPortal_Fetch of the WageTypes collection (list) I have this...

        private void DataPortal_Fetch()
        {
           
            // get all the payment methods from the database.
            TWagePaymentMethods paymentMethods = TWagePaymentMethod.SelectAll();

           
            foreach (var item in paymentMethods)
            {
                WageTypes w = this.AddNew();
                w.Description = item.Description;

                //using (w.BypassPropertyChecks)
                //{
                //    DatabaseHelper.CopyProperties(item, m, string.Empty);
                //}

            }
        }

 

This appears to work but I have 3 questions. 

1)  The WageType object when created with .AddNew  has it's IsNew property set to true but in your example code in your eBook I didn't see any example of this unless I missed it.  IsNew should be false.  So what should I do?

2)  Why can't I do the BypassPropertyChecks like in your book.  If I uncomment this, the compiler complains that it isn't a property of the object.

3)  Is this even the correct way to do this?  My goal is simple,  load the values in a grid and let the user change them at will, add new ones, delete, etc.  Standard stuff.

Thanks again for any help.

Mark


Viewing all articles
Browse latest Browse all 764

Trending Articles