More in this section

Forums / Developing with Sitefinity / OdbDataProvider provider = NolicsHelper.SetConnection("DefaultConnection", "Jobs");

OdbDataProvider provider = NolicsHelper.SetConnection("DefaultConnection", "Jobs");

2 posts, 0 answered
  1. Tim
    Tim avatar
    156 posts
    Registered:
    23 Sep 2007
    14 Nov 2007
    Link to this post
    Sitefinity Team,

    I'm having problem understand the following code in the Intra-job site sample:
     Assembly assembly = typeof(Job).Assembly; 
        DataConnection.Initialize(false, assembly); 
        OdbDataProvider provider = NolicsHelper.SetConnection("DefaultConnection", "Jobs"); 
        //Upgrade the database with the defined data objects for the Jobs module. 
        provider.Upgrade(); 

    I didn't see any "jobs" provider has been created in the project. Please give me some hints.

    Thanks
    Tim
  2. Sonya
    Sonya avatar
    231 posts
    Registered:
    24 Sep 2012
    15 Nov 2007
    Link to this post
    Hello Tim,

    When the Sitefinity application starts, it creates instances of all modules in the system. It is looking for pluggable modules in the web.config and Intra-site modules in the App_Code.
    So, all you need to do in order to write an intra-site module, is to create a class in the App_Code folder that inherits the Telerik.WebModule abstract class. All module instances are created with Reflection by calling a parameterless constructor. So, the best place to initialize the Jobs provider is the static constructor of the JobsModule.
     
    In other words, if you would like to create and use a different data provider, this is the place where you initialize it:

    Assembly assembly = typeof(Jobs).Assembly; 

    The Jobs data provider is declared in the Telerik.Samples.Jobs.Data project referenced from the JobsIntraSite sample site.

    With the line below, you set the Nolics provider which will be used by Jobs data:

     provider.OdbDataProvider provider = NolicsHelper.SetConnection("DefaultConnection""Jobs"); 


    Greetings,
    Sonya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
2 posts, 0 answered