0

Trying to create a web service to use Petapoco, I have created the following in 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";
        }
    }
}

However, using this from a web service call results in

 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");

Any way to fix this?

Mivaweb
  • 5,580
  • 3
  • 27
  • 53
YesGenesisCamel
  • 173
  • 1
  • 12

1 Answers1

0

Umbraco wraps its use of PetaPoco, so if you want "clean" and separate use of PetaPoco, you will need to reference it in your project or in your case (when not compiling) place PetaPoco DLL(s?) in the bin folder.

Or you could google PetaPoco Umbraco and see how PetaPoco is used in Umbraco context. According to http://www.wiliam.com.au/wiliam-blog/using-petapoco-with-umbraco-is-pretty-sweet it goes something like this (for your example):

var db = applicationContext.DatabaseContext.Database;
// or ApplicationContext.Current.DatabaseContext.Database

if (!db.TableExist("blahblah"))
{
    db.CreateTable(false);
}
Jannik Anker
  • 3,320
  • 1
  • 13
  • 21