Is it possible to create a business entity that is a mix of 2 table or more?

Topics: General Discussion Forum, Service Factory Modeling Edition Forum
Mar 23, 2007 at 2:14 PM
Hi,
Again new to WSSF ,so be patient if I ask a silly question.
The majority of our in house Stored procedures have parameters/fields that belong to more that one table.
EG when we retrive a Customer object we also pull addresses,phones etc .... in 01 shot.
Is it possible to create a business entity that is a mix of 2 table or more?
If possible how do you do that?


Thanks in advance

Mar 23, 2007 at 5:24 PM
Edited Mar 23, 2007 at 8:47 PM
Maybe is a good practice to make an facade stored prodedure that collect all customer specific information and gets simultaneously back. (You have sprA(x), sprB(y), sprC(z) and create and 'god' procedure named sprD(x,y,z).)

Another way is to overwrite the generated CustomerFactory / CustomerInsertFactory and maybe CustomerRepository but this is unavoidably lot's of hand-work.
Mar 23, 2007 at 8:38 PM
If you always pull your customer object with all the associated data, you might just want to create one stored proceudre like bojxx suggested. For example, something like dbo.getCustomer @customerId

SELECT * From Customer Where CustomerID = @customerId
SELECT * From Address Where CustomerID = @customerId

In the datareader, you can call the NextResult() method to read the next resultset (in this case, the Address data.
Mar 23, 2007 at 8:54 PM
Thanks guys for your replies.
Bojxx
not sure I understand,the scenario is this :
we are moving from vb6 to c# soa architecture and I am evaluating WSSF.
We have 3000+ Sps and this sps are optimized etc.We are not going to modify our SPS.

From what i can see and I understand WSSF does a lot for you,but it's not that flexible,and pls correct me if I am wrong but its more of a generator to get you started and guide you rather than giving flexibility.
I am not sure if you can create your own recipe but I would not know where to start.

MikeBosch
For the reason explained above we are not modifying our sps.

Is a pity I cannot model by Object Entities.May be I am wrong but I dont want 1 entity x table.I want to decide what my entity looks like.

I wish people in the community posted their own samples ,so that we WSSF beginners could get more of an idea.

Thanks again and please advice if you have any more suggestions

Thanks
Mar 23, 2007 at 9:16 PM
What's about my second suggestion? You can re-use and extend the factory and repository classes. After understanding the logic of the repository-object factory-criteria approach, you can easily adopt it to your needs. Construct(IDataReaderreader) in <..>Factory and ConstructSelectCommand in <...>SelectionFactory is a good startpoint.

Developer
Mar 24, 2007 at 5:05 PM
Since you have more than 3000 SP and you may not be able to update them, you might want to adapt/extend the factory as bojxx mentioned and you may also take a look at the Community Contributions and see if you find something that fit your needs or gives you a head start.
On the other hand, stay tunned for the upcomming WCF+ASMX Hands-on lab that will be updated anytime from today and will give you many tips on how to update/extend the factory guidance packages and many other features.

Thanks,
Chalry
Mar 26, 2007 at 3:16 PM

bojxx wrote:
What's about my second suggestion? You can re-use and extend the factory and repository classes. After understanding the logic of the repository-object factory-criteria approach, you can easily adopt it to your needs. Construct(IDataReaderreader) in <..>Factory and ConstructSelectCommand in <...>SelectionFactory is a good startpoint.



That is the problem ,I dont think I understand the Criteria fully,and how use it with multiple stored procedure not inline sql.
Criteria
So you have 4 SPS EG (one retrieves customer by ID)(one by Country)(one the customer with most sales ) etcc.....
How can I adapt the Criteria Class?(Inline sql is out of the question).

The problem is we are not going to make our lives more difficult by rewriting more than we should.


For reading yes we are going to use the dr.NextResult.

Is it possible to create Composite object?Is there an example somewhere?
I think the lack of examples can create some confusion or not I could miss how I could maximise the WSSF.

Regarding the Community contribution at the moment there is only 1 example.

Thanks a lot

Mar 26, 2007 at 4:39 PM
how use it with multiple stored procedure not inline sql (..) How can I adapt the Criteria Class?
No doubt, this is a good question. ConstructSelectCommand creates a DbCommand and Construct reads one datareader so you can't easily adopt for more stored procedures. I see a solutions but no nirvana:

Create an second-level repository. This repository calls the generated repositories. In this case, the guidance package extension on the community section is a good tool: you can generate stored procedures independently. Of course, the final Construct command is your job.

Is it possible to create Composite object?Is there an example somewhere?
This is my problem too:) (see 'Composite object?' post in discussion list)
Developer
Mar 27, 2007 at 3:44 PM
AS far as I know, the Composability scenario is very likely to be included in version 3 of WSSF.
For the time being there some good articles out there about the subject (Patterns for High-Integrity Data Consumption and Composition)