Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tim C 161 posts 528 karma points
    May 29, 2016 @ 07:09
    Tim C
    0

    Using petapoco from my own web service

    I have created a cs file in App_Code

    using System;
    using Umbraco.Core;
    using Umbraco.Core.Persistence;
    
    
    
    
    namespace utData{
    
        public class MyDB{
            public string demo(){
                 var dataContext = new PetaPoco.Database("umbracoDbDSN");
                return "demo - OK";
            }
        }
    }
    

    in my web service

     public String dbTest()
       {
           string T;
           T = "Latest testing";
           MyDB d = new MyDB();
           T = d.demo();
    
    
       return T;
       }
    

    this crashes

    CS0246: The type or namespace name 'PetaPoco' could not be found (are you missing a using directive or an assembly reference?)

    var dataContext = new PetaPoco.Database("umbracoDbDSN");

    What am I missing in utData?

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    May 29, 2016 @ 18:45
    David Brendel
    0

    Hi Tim,

    if you use umbraco core then you can use the Umbraco database context.

    ApplicationContext.Current.DatabaseContext.Database.

    There is no need to create a new database instance.

    Regards David

Please Sign in or register to post replies

Write your reply to:

Draft