Copied to clipboard

Flag this post as spam?

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


  • BaconBeastNz 40 posts 60 karma points
    Mar 16, 2011 @ 07:24
    BaconBeastNz
    0

    Is it possible to access the Umbraco DataContext (I.E SQL connection) ?

    Hi there

    I am doing some LINQ2SQL, as I have a pretty unique DB schema I'd like to stay out of the Umbraco system (I.E using Nodes & properties to store this particular data)
    I'm trying to link my C# classes to the DB tables using E.G

    "Table<Customer> Customers = db.GetTable<Customer>();"

    but I first need to setup a DataContext db = new DataContext();

    As I'm already connected to the DB with Umbraco, is it possible to grab that DataContext instead of creating a new one?

    Thanks any help appreciated! :)

  • Harald Ulriksen 207 posts 249 karma points
    Mar 16, 2011 @ 09:21
    Harald Ulriksen
    0

    Hi,

    umbraco use old style queries and execute*.

    You can access sql helpers in umbraco.BusinessLogic.Application.SqlHelper located in buisnesslogic.dll, the rest of the data things are in umbraco.datalayer.dll

    Hope this helps,
    H.

    As note I used Simple.Data, https://github.com/markrendle/Simple.Data, for the last project. Simple.data works great with umbraco 4.6 and sql compact 4. I had a very simple schema for my non-umbraco data, not sure how suitable this will be for more advanced schemas.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies