Why to trasnslate between DC and BussinessEntites ?

Topics: General Discussion Forum, July and December Releases Forum
Feb 13, 2008 at 1:32 PM
hi,
Please any body help me.. i am really stuck up with some concepts...

Why we have to translate between DC and BussinessEntites ?
Alos while creating service contract translator using the wizard...,
The process which i am trying to do is inserting some datas into the DB.

first page:
First class to map----> what i have to mention here ? DataContract or Classes in Bussiness Entites ?
Second Class to Map---> what i have to mentin here ? " " " " ?
Is it possible to change the name of mapping class, i tried to change but the class name dosent change.

Let me tell what i did here ?
I selected---------> First class as DataContract,(4 Data Members)
Second Class as Bussiness Entites..
in the seciond Page i can see property mappings. In the Datacontract listbox all four are showing with their datatype, but in the Bussiness entites, i can see all the four members, but some of the datatypes are shown as nullable `1.

Can anybody tell me the solution for this....

Thanks and Regards
Nimesh Prabhakar


Feb 13, 2008 at 3:37 PM
Howdy Nimesh,
We can talk about this issue, along with the other posting you had.
The reason we translate between BusinessEntities and DataContracts is that DataContracts are what you inform your consumer they MUST adhere to. This is similar to a loan contract. Your lender says you need to send them X amount of money every month and they will do something with it. You send your lender X amount of money each month and they do something with your money, i.e. pay off part of your principal loan amount, pay for part of the interest you owe, pay for taxes, pay for insurance and so forth, but you don't worry about that because you simply send your money. The DataContract is similar to you sending the money to the lender. The consumer agrees to call your service with the correct data type, an instantiation of the DataContract object, and the consumer expects you to do something with that. Now, you could use only the DataContract in your service, but if you also utilize the Repository Factory that we discussed in your other posting, you will see that the BusinessEntity is a different beast than the DataContract. There might be more or less properties available in the BusinessEntity than in the DataContract, it is up to you to decide what is correct in your situation.
To answer your second issue regarding nullable ‘1, I have found that is what is generated when using generics. So instead of List<MyObjectType>, you may get List’1 or some such thing.

If I am off base here, could someone please let me know?

Feb 14, 2008 at 7:51 AM
Hi,
Now i am clear with the Data Contraact and Bussiness Contract.
One thing i would like to more is that from where we have to call this translate class.
From the adapter class we have to call right ?
I have to translate the DC to BE, the process is to insert customer details..
i need assistance for this process.

Nimesh Prabhakar
Feb 14, 2008 at 1:12 PM
Howdy Nimesh,
Please see my earlier reply to your question in discussion:22113, that goes into answering your question.
Developer
Feb 14, 2008 at 1:12 PM
The translator recipe that you can find right clicking on your service implementation project will generated code (the translators for DC->BC and BC->DC) where you can use in your adapter class. Now in order to assist you with the creation of the translators, I'll need some details about your "First" (DC) and "Second" (BC) types and which properties you have on each in oder to map them. In case you don't want nullable types in your DC, you can set the IsNullable property to false.
Feb 25, 2008 at 8:20 AM
Hi CF,
Here ia mgiving the list of my DataContract,
CustomerID----int32;
CustomerName----string;
JoinedDate----datetime;

and Here goes my BE... same as my DC(fieldNames).

I have created a class called InsertCustomerClass in the BussinessLogic. I would like to insert customer details into the database.
So ho i have to write the Codes for the same.

if the action is sucess then it must return a bool value.

i am really stuck up with this things...

Nimesh
Developer
Feb 25, 2008 at 1:07 PM
Check thread http://www.codeplex.com/servicefactory/Thread/View.aspx?ThreadId=22778 where you can find the links to samples for this (WSSFv2 RI apps).