Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

good use of my unit of work?

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
scm0sml
Asked:
scm0sml
1 Solution
 
Paul JacksonCommented:
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now