.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Is it a good practice to use DataContract attributes on business entities

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :WCF
Hi Folks, Currently I am developing a framwork for travel industry and finally my framework will expose its operations in the form of WCF Service. I was wondering if it is a good idea to decorate your entities and class with DataContract attributes. I know this is required if you want your classes/fields to be serialized/deseralized.  However, by Adding these attributes mean you are making your entities service specific which I believe not a good idea. Service and domain specific entities should be seperate. One solution to this would be to make DTOs and decorate them with these attributes and this make sense as core purpose of these DTOs is serialization and deserialization. What can be other options....? Please share your thoughts. Thanks, Naeem

View Complete Post

More Related Resource Links

Problem: DataContract and DataMember attributes are not being recognized

I am having a strange problem. My service is otherwise working fine. However, now I want to add a custom object to be sent over to clients. I created a class to hold the data applied DataContract and DataMember attributes. However, compiler is not recognizing these attributes and giving me following error. The type or namespace name 'DataContractAttribute' could not be found (are you missing a using directive or an assembly reference?)  I could not figure our what assembly do I need to refer to. I am using VS2010 on WinXP. Thanks. kr

SSIS - Adjusting command timeout (good or bad practice)

Hi,   I'm building a bank reconciliation process where I'm leveraging SSIS to import, transform and insert data into a database.  I had a command timeout error at the transformation segment (Derived Column methods). At first was it difficult to determine (Ambigious SSIS errors), but in the end was easy to resolve.  I simply increased the timeout duration. Being a developer, I find this to be bad practice as the application should be optimized as much as possible prior to making a timeout adjustment.  An ideal method would have been to cache more data prior to calling the database command, so the data is available for processing and not keeping the command open unnecessarily. I'm relatively new to SSIS, but have been unable to determine a method to remove the transformation bottleneck. I could do it easily enough with customized .NET code, but I'd prefer not to do that.  My question - There must be a method in SSIS that buffers the data originating from the transformation prior to calling my INSERT to database method?   Thank you,   Russ

How do i pass my datacontract into my business layer without a circular reference????

Ok, this architecture is fairly new to me, so I need a few good pointers.  I've searched the topic, but still don't have a clear understanding on what I'm missing.   I have a presentation layer, which displays my data and forms. I have a WCF service, a business layer and a dataAccess Layer I am trying to read data from on OLD!! foxpro .dbf file.  I've read all the articles on why not pass Datasets, etc so I'm trying to learn how to pass data contracts.  I have the following in my WCF [ServiceContract] public interface IService1 { [OperationContract] void SaveNDFData(string storedprocedure, ndfContractLibrary.NDFDataParam[] ndfData); <strong>[OperationContract] List<ndfContractLibrary.NDFDRawData> getRawNDFD();</strong> } I have a separate library for my dataContracts as i know later I will have several.  I'm using this as a generic List<> [Serializable] [DataContract] public class NDFDRawData { private int batchNumber; [DataMember] public int BatchNumber { get { return batchNumber; } set { batchNumber = value; } } private int sampleNumber; [DataMember] public int SampleNumber { get { return sampleNumber; } set { sampleNumber = value; } } private decimal invitroHour; [Da

How to execute workflows for business entities within a singular transaction



Let's assume we have a simple usual situation, we have these business entities:

  1. Sales man.
  2. Customer.
  3. ProductInstance.

Let's assume that each business entity has its own workflow defining it's lifecycle. Let's assume that a sales man's selling of a productInstance to a customer should be done by some advancement of each of the three business entities' workflows. It's obvious these advancements should be done within a singular transaction.

Can't you provide a hint on how to establish the transaction and how to scope the advancement of each of the three workflows by the given singular transaction, please?


Best regards,

Hwenrik Dahl


Join Entities in BDC For Business Data Field In List



I'm having a devil of a time joining two tables for a BDC to be used as a Business Data field in a list. I've seen plently of examples  connecting two tables to use with web parts, however i haven't seen anything about using an association in a list. Before i continue to beat myself up i need to know that this is possible.


If that's confusing here's what i'm trying to do.

I have two tables Locations and Region. I need the Region_Name from the region table based on the Location_Id (primary key) from the Location table. Locations is connected to Region by Region_id as a foreign key.


Any help would be immensely appreciated.

Best Practice for writing DataContract for a multi row data set.


My Stored Procedure returns the following fields: DisplayName, CompCode, CompName, CompValue, CompFlag. For any caseid there may be multiple rows returned.

I want my WCF Web Service to  expose all the above mentioned fields in wsdl.

How should I write my DataContract so that the xml has multiple rows.

Is it ok to to put List<string> in DataMembers as shown below or is there another best practice?

        public List<string> DisplayName { get; set; }


Thanks You.


Is returning ArrayList of Datasets good practice?



I am requesting data via an API which returns an XML every time. Then I need to analyse this XML and keep some of its elements.

I save that XML to a DataSet.

However, I need multiple calls to get multiple responses, and then group the elements from the various responses together, for example:


This would be a typical XML response. I need to get the myData field from say 10 different XML.

Now, I've been putting every XML response in a new DataSet and creating an ArrayList which holds them, and then itterate through the DataSets. I find this quite slow, and I think (correct me if I'm wrong) that DataSet it's an expensive means as far as memory is concerned.

What would you advice me to use in this occasion?


Will it be a good practice to submit form data through web service method?



I am trying to submit my form's data to database using asmx Web Service method(Through AJAX extension methods i.e., Script callback method). My form contains lot of data, though only text data.This will be a very fast process,but still i want to get some advice from you expert persons that should i processd in the same way ?Or should i submit form data in the traditional way ?

Please give proper reason for your answer.

Business entities in WF variables. How to persist?


Hi there,

I have a long-running workflow, that uses some business entities (using Entity Framework 4) in its variables.

I'd like to preserve those variables during unload/reload phases.

What I don't like is to store them together with workflow in binary form, just their primary keys.

After reloading the workflow from instance store, I need somehow to refresh all business entities from database, using primary keys, stored in workflow.

I definitely don't want to write custom activities to refresh my variables, because workflow is defined by the end user. So refresh should work transparently.


How do I proceed with my task? Where do I begin?

which one is the good practice to consume WCF/Web Service in client side ?



There are so many method to consume webservice/WCF in client side, like using Jquery and Ajax Scriptmanger. Which one is good practice to implement in

project and why ? could you share your opinion ?


Thank you

Business Modelling and Web Applications and extending UML

UML can be used to model a business, prior to automating it with computers. The same basic UML syntax is used, however, a number of new symbols are added, in order to make the diagrams more relevant to the business process world. A commonly-used set of these symbols is available in current versions of Rational Rose.

ASP.NET 4.0 Dynamic Data and Many to Many Entity Framework Entities

I did not play much with Dynamic Data controls in VS2008 and just made a cool discovery in VS2010 Beta 2. This may not even be new, but as I'm sitting 30,000+ feet over the Atlantic ocean, I don't have access to VS2008 at the moment to check.

Good way to do a Many-to-Many relationship?


I've used the automatic  Many-to-Many generation as described here: http://msdn.microsoft.com/en-us/library/dd742359.aspx

But that doesn't seem to allow a quantity to be attached to orders (in the example it would be courses). I have many customers and many products, I would like a customer to be able to order more than one product. Right now I get a grid of checkboxes. I would like instead a field where I could enter a number. 

Is this possible?

Business Intelligence Development Studio



            I installed Visual studio 2008. I want to open Reports. I want to install Business Intelligence development studio for that.

May I know how to install that one. Is Business Intelligence development studio comes with Visual studio 2008.

Please tell me, I m new to this concept.


Business Intelligence Reports Project in Visual studio 2008 ?



I wonder how to add a project template called  Intelligence Reports, something like that, to Visual studio 2008. I have SQL 2008 installed. Do I need to install some updates to get Intelligence Reports template to Visual studio 2008 ?

Thank you..

Business object design in master details.


Hello guys, I have the following scenario,

  1. There is a master business object containing 40 fields
  2. 2 separate child business objects
  3. If I update a child record, I have to update master's 'Last modify by' status along with 3 or more fields in master
  4. For this purpose, I don't want to initialize a separate Master class object (as most of the fields are unused/wasted)
  5. The 'last modify by' also gets updated if the records in master get updated themselves

Currently I have separate business objects for master table, Child 1, Child 2 etc.

How do I control this in my business object design ? Do I break up my master object ? Say I extract last 'modify by ' into a new class, through inheritance or some other way ?

Is there a way that whenever child gets updated I use a 'small' class to update Master status only and whenever the master itself gets updated I do the same.

Problem is that I am having redundancy in my small class (Master class also contains 'Last Modify By ',

What would you advice. Please have your say. Thank you.

Edit  I am using webforms guys.

Want to create Online Business Card designing functionality


 I am going to create Online Business Card designing functionality.

 I am newbie regarding graphics in asp.net. I want to create exactly like following site.




I have some questions


1) How can I write user text in existing image on the fly?

2) How to embed that with aspx page?

3) How to generate it with user inputs like text, font color, size?


Please give me any tutorial URL or any link that could help. Is there any compo

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend