Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

good use of my unit of work?

Posted on 2012-03-23
1
158 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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