Quantcast
Viewing all articles
Browse latest Browse all 764

DataPortal.Fetch - why return object when no data?

This seems non-intutive to me:

BusinessObject bo = BusinessObject.GetBusinessObject(id);

If 'id' is valid you get a business object as you expect.  But if id is a value that doesn't return a record in the database wouldn't you expect 'bo' to be null?

To get around this I've added the following code:

public static BusinessObject GetBusinessObject(id)
{
    BusinessObject o = DataPortal.Fetch<BusinessObject>(new Criteria(id));
    if(o.Id == 0)
   {
       o = null;
    }
    return o;
}

But I'm curious if maybe there should be something different in the DataPortal_Fetch override instead?

Viewing all articles
Browse latest Browse all 764

Trending Articles