0

Our WCF services return Datasets to the webserver,

In the new .NET web site we are going to use MVC 5. Since MVC 5 framework works really well with known business objets (validation framework etc.), we need to convert Datasets to known business objects in the Model classes.

We tried following conversion,

public List<Category> GetCategories()
    {
        List<Category> cats = new List<Category>();

            DataTable dt = //get data table from the dataset;
            foreach (DataRow row in dt.Rows)
            {
                Category cat = new Category();
                cat.CategoryID = int.Parse(row["CategoryID"].ToString());
                cat.CategoryName = row["CategoryName"].ToString();
                cat.Description = row["Description"].ToString();
                cat.Picture = GetBytes(row["Picture"].ToString());
                cats.Add(cat);
            }

        return cats;
    }

Assume that we retrieve and unpack the data table. Will this be an expensive conversion if there are 100s' of request per second accessing this code block? What would be a better way to test the performance under load? Or is there a better approach to solve this problem?

Really appreciate any help on this.

1 Answer 1

2

I would not worry about the time it takes to convert the DataSet to domain objects since it's going to be a fraction of the remote call to get the data through a remote service. However, for result sets that rarely change I would recommend adding caching around the resolved domain objects to avoid the conversion, but more importantly avoid the WCF call and subsequent DB call.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.