Solved

good use of my unit of work?

Posted on 2012-03-23
1
155 Views
Last Modified: 2012-03-27
Hi,

I have the following page load method:
 
protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            using (var db = new PublicUnitOfWork())
            {                
                DisplayPageCMS(litPageTitle, litMetaKeywords, litMetaDescription, litBodyText, db);
            }
        }
    }

Open in new window


It calls the following method in my base class:
public void DisplayPageCMS(Literal litPageTitle,Literal litMetaKeywords ,Literal litMetaDescription,Literal litBodyText, PublicUnitOfWork db)
    {
        Page p = db.Pages.FindById(1);

        //do some work to set the lit values of my meta tags etc
    }

Open in new window


I'm just wondering is the best way to use my PublicUnitOfWork or should the base class function be creating its own.

Note in my page load I may want to use the publicunitofwork some more for other things...

I'd appreciate some input/feedback on this.

Thanks
0
Comment
Question by:scm0sml
1 Comment
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
ID: 37758051
If you are going to PublicUnitofWork in yur page_load for other things then what you are doing is fine, why create a 2nd instance when you already have created one.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now