How do I filter a business object by a custom property?


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
When I attempt to filter a BO on a custom property, the debugger tells that the specified column does not exist.  It is true that it cannot be found in the DB, but it is on the BO.  Is there a trick to filtering on a custom property?

Thanks,
Bill

Replies
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Greg McGuffey (01/28/2008)
It really has nothing to do with the custom property, but everything to do with the columns in the underlying DataTable

I am starting to see that.  Nevertheless, I am still quite confused about the custom property thing.  To me, the business object is an ideal place for some of these things.  The database is not the best location.  You and Trent are suggesting that I need to relocate the business logic back into the database.

Here is an example of some custom properties on the Parts business object that I have (declarations/tags/comments removed for brevity):

public int OnWorkOrder
{
   
get
   
{
       
string mPartindex = this.partindex.ToString();
       
return (int)ExecuteScalar("spx_GetAmountOnWorkOrder '" + mPartindex + "'");
    }
}

public int OnSalesOrder
{
   
get
   
{
       
string mPartindex = this.partindex.ToString();
       
return (int)ExecuteScalar("spx_GetAmountOnSalesOrder '" + mPartindex + "'");
    }
}

public int RequiredQty
{
   
get
   
{
       
int mReqQty = (this.minstocklevel - this.onhandqty) + (this.OnSalesOrder - this.OnWorkOrder);
       
if (mReqQty < 0) mReqQty = 0;
       
return mReqQty;
    }
}

As you can see, the logic becomes rather complex.  Easily handled in the business object.  The stored procedure that would handle this same stuff would be atrocious...doable, but a near nightmare to construct.  I really do not want to put all this back into the DB.  If I do, then these custom properties become unneeded.  In fact, I cannot see a good use for custom properties, since all of this can be done in the DB.

Bill


Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
A custom property shows up in the field list when creating a browse dialog.  I receive the following error when trying to execute a search on a custom field:

ArgumentException
  An item with the same key has already been added.

Source     : mscorlib

Stack Trace:
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogSearchingEventArgs..ctor(BrowseDialog Browse, WhereStatementCollection WhereStatements)
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.ExecuteSearch()
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.tsiSearch_Click(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
   at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Thought I had something there...I was going to plop a browsedialog on the form and force the user to work through that (with the custom property set to not visible).  Not sure what that error means, but I assume it is saying, "Uh uh uh!".  That won't work, I guess.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Bill Cunnien - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Bill Cunnien - 17 Years Ago
Greg McGuffey - 17 Years Ago
Bill Cunnien - 17 Years Ago
                         A custom property shows up in the field list when creating a browse...
Bill Cunnien - 17 Years Ago
Peter Jones - 17 Years Ago
Bill Cunnien - 17 Years Ago
Greg McGuffey - 17 Years Ago
Bill Cunnien - 17 Years Ago
                 Guys, can I do this? foreach ( DataRow dr in this...
Bill Cunnien - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Peter Jones - 17 Years Ago
Bill Cunnien - 17 Years Ago
Charles R Hankey - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Bill Cunnien - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Trent L. Taylor - 17 Years Ago
                         [quote]Thanks for pulling out the French. English just wasn't getting...
Greg McGuffey - 17 Years Ago
Bill Cunnien - 17 Years Ago
Trent L. Taylor - 17 Years Ago
                         Thanks, Trent! Man, I am getting tired...past midnight here. Still...
Bill Cunnien - 17 Years Ago
                             I added the code below into the CurrentDataTableRefilled method:...
Bill Cunnien - 17 Years Ago
                                 If I put a break on the first line of the code in the custom property,...
Bill Cunnien - 17 Years Ago
                                     Well, you need to have data in the colReqQty for the filter to work,...
Greg McGuffey - 17 Years Ago
                                         The fire is already crackling loudly under my feet. I'll go through...
Bill Cunnien - 17 Years Ago
                                         Fascinating. Bewildering. Frustrating. There are three custom...
Bill Cunnien - 17 Years Ago
                                             Some more thoughts (do I smell something burning?)....:P
...
Greg McGuffey - 17 Years Ago
                                                 Bill, I think that you are trying to make this too complicated. I...
Trent L. Taylor - 17 Years Ago
                                                     One other point that I saw in regards to your grid...if you do not...
Trent L. Taylor - 17 Years Ago
                                                 Here is my actual custom property code. Please criticize at will. I...
Bill Cunnien - 17 Years Ago
                                                     Hey Bill. Just in case it might help you see what Trent told you about...
Ivan George Borges - 17 Years Ago
                                                     Bill,

You might try doing something real simply like just...
Greg McGuffey - 17 Years Ago
                                                         Paul: I have a very similar setup on my InvoiceBO with the...
Bill Cunnien - 17 Years Ago
                                                             BILL, if you would read my previous post, there is ONLY one...
Trent L. Taylor - 17 Years Ago
                                                                 Also, if you read Ivan's post, he has posted some code that shows an...
Trent L. Taylor - 17 Years Ago
                                                                     [quote][b]Trent L. Taylor (06/26/2008)[/b][hr]Also, if you read Ivan's...
Bill Cunnien - 17 Years Ago
                                                                         If your customer property work's fine with textbox's but not with a...
Paul Chase - 17 Years Ago
                                                                             [quote][b]Paul Chase (06/26/2008)[/b][hr]If your customer property...
Bill Cunnien - 17 Years Ago
                                                                         Hey Bill. Don't even know wether this would make a difference or not,...
Ivan George Borges - 17 Years Ago
                                                                             Thanks for reviewing the code, Ivan. Yup, just left it out, since I am...
Bill Cunnien - 17 Years Ago
                                                                                 I thought I would try to wrap up this thread with a play-by-play of...
Bill Cunnien - 17 Years Ago
                                                                                     Glad you got it going, Bill! ;) [quote]There are a couple of...
Ivan George Borges - 17 Years Ago
                                                                                         Since the form's purpose is to display information only, I set the...
Bill Cunnien - 17 Years Ago
                                                                 The threecolumns (which areblank)are dragged from the available...
Bill Cunnien - 17 Years Ago
                                                 Bill, Try taking the business binding source out of the equation,...
Paul Chase - 17 Years Ago
                                                     With the textboxes, the values are showing up properlyas I navigate...
Bill Cunnien - 17 Years Ago
                                                         Hi Ivan, Thanks for the input. The only real difference is that my...
Bill Cunnien - 17 Years Ago
                                                             That is good, if it work's without the BBS then you know it is a BBS...
Paul Chase - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search