Multiple Tables in an object


Author
Message
Robert Harvey
Robert Harvey
StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)
Group: Forum Members
Posts: 9, Visits: 28
Let's say I have a strongly-typed dataset that contains multiple tables.  And, let's call this dataset 'Orders'.  How can I create an object with Strata-frame?  All of the documentation points to one table per object.  Not that the attachment is a 'real-life' example.  But, I don't want to upload what I use at our company for public consumption.
Attachments
XSDSchema1.zip (148 views, 1,013 bytes)
StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
OK,



I definitely agree that you should never post anything on this forum that is part of your company’s product. And this example definitely says what you need it to say.



There are a few ways you could handle this all are based on the assumption that the sample you gave actually comprises 2 tables within the database (we are talking about a relational database, right?).



1)Create a business object (we’ll call it CompanyBO) and map it to the Company table. Create a business object (we’ll call it StateBO) and map it to the State table. Work with the two separate business objects in code (when you populate the CompanyBO, you can turn around and populate the StateBO etc...)



2)(the better way) Create a complex business object made up of a business object within a business object (result will be similar to the way an Object Relational Mapper would handle it). You could override the State property to return a StateBO object that is automatically filtered based upon the ParentRelationship. When you populate the CompanyBO, it would automatically populate an internal StateBO that would be returned through the State property.



What language are you working with and I could send you a sample project on how I would do it.
Daniel Essin
Daniel Essin
StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)
Group: Forum Members
Posts: 235, Visits: 309
Perhaps you could post this sample for downlaod. I use C#.



Thanks
Robert Harvey
Robert Harvey
StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)
Group: Forum Members
Posts: 9, Visits: 28
I have created a similar object using CSLA.  But, it was an icky amount of code to accomplish this.  I started with a base object that inherited System.Data.Dataset.  Then I inherited that object and exposed a dataset property.  A getOrder method to fill it. 

Oh yeah....I use VB. 

Robert Harvey
Robert Harvey
StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)
Group: Forum Members
Posts: 9, Visits: 28
But, you can post in C#.  Either way works for me.
StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
I'll get it posted ASAP in the morning.
StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
OK, I've uploaded a sample for both C# and VB. Both are identical except where they add the handlers for the events, of course. A little explaination is in order for the samples:



1) All of the necessary code is contained within the "Necessary Code for Complex Business Object" region in the CompanyBO.* file.

2) No extra code was added to the StateBO.

3) You will have to go into the Business Object Mapper and "customize" the State field on the CompanyBO and set it to use "custom code" that will return the readonly property containing the StateBO.

4) I updated the MicroFour StrataFrame AddIns.dll to modify the Business Object Mapper so that it will not create a FieldPropertyDescriptor for a field overriden with custom code. It will be available in the next update. So, if you reproduce this sample before the next update, you will just have to delete the FieldPropertyDescriptor that is created for the State field on the CompanyBO (it won't work and will just assume the field is still a System.String).



---------------------------

Remember, a business object in StrataFrame is just a class, so anything you want to do with it, you can. Just don't modify the designer file outside of the "Component Implementation" region or your changes will be overriden.
Attachments
ComplexBOSampleCS.zip (173 views, 705.00 KB)
ComplexBOSampleVB.zip (167 views, 111.00 KB)
Michael Cobb
Michael Cobb
StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
Hi Ben.  I'm struggling to understand the VB sample. 

You will have to go into the Business Object Mapper and "customize" the State field on the CompanyBO and set it to use "custom code" that will return the readonly property containing the StateBO.

Do I need to create a custom field property for the state in the CompanyBO?  In the Business Object Mapper, what do I need to put in the "custom code" for the State field on the CompanyBO? 

I updated the MicroFour StrataFrame AddIns.dll to modify the Business Object Mapper so that it will not create a FieldPropertyDescriptor for a field overriden with custom code. It will be available in the next update. So, if you reproduce this sample before the next update, you will just have to delete the FieldPropertyDescriptor that is created for the State field on the CompanyBO (it won't work and will just assume the field is still a System.String).

Meaning I would not check the box to create a descriptor?  I apologize for being slow.  Is there a sample project that illustrates the use of the BO Mapper to create custom code?

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
No, sorry, there aren't any samples that include any of the data for the business object mapper (because we would have to put records into the StrataFrame database to do so...).  So, to explain things a bit better... on the custom code, you would want to put the exact code that would be replace the property that you are customizing.  Meaning that whatever you put in the custom code box will be placed in the partial class as the code for that field property; so, if you wanted to not include a field, then just customize it and leave it completely blank...

As for your second question, yes, you would want to leave the Create Field Descriptor unchecked or the BOMapper will create the FieldPropertyDescriptor for that property.

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Trying to follow along here and perhaps someone will take pity on the XML challenged. I see the XSD schema so I can easily visualize the table structures we're talking about. I see these are not tables currently in the SF sample data.



I downloaded the sample and see to BOs, but I of course have nothing to map them to in sql server.



Since Robert passed his data structure as an XSD Schema and Ben had that data structure in the BO in the sample I think I might be missing something everyone who is not VS - XML challenged knows.



Is there a command to create the tables in SQL Server from the XSD schema ? Aside from doubleclicking the schema and seeing it open into a nice data diagram in VS2005 are there other tricks you can do with it in sql server / VS / DDT that one should know about ?



(understanding everything else involved in the complex business object sample will just require my wading out of the newbie phase in SF )



Any guidance appreciated.

Unsure







GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search