Copied to clipboard

Flag this post as spam?

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


  • Thomas Hansen 2 posts 22 karma points
    Sep 15, 2010 @ 22:39
    Thomas Hansen
    0

    Urgent! Help Needed with LinQ to Umbraco

    Hi There,

    I'm pulling my hair out to get this to work. In my mind it should be fairly simple, but it just don't want to work.

    Base info:
    System:  Umbraco 4.5.2

    Goal
    I have a webservice. This webservice receives some data, one of these is a "Web Category Id". I have to search my Tree for this category. For this purpose i have made a document type called "ContainerProductCategory" and have made a property called "id" (alias CategoryId). When i have found this Node i will use this as the Parent for my new Node which is a "product" document type.

    Problem
    So far i have used the "Export to .NET" on the document types, put the .cs files in the App_Code folder, and i my webservice refferenced to the namespace of it. I have no errors a all, but when i try to call the webservice, it returns no nodes ("System.InvalidOperationException: Sequence contains no elements"). I have made the categories in the Tree and can see them there, but they apperently can't get selected when i use the LinQ

    My Webservice code

    public

     

     

    class Hedensted : System.Web.Services.WebService {

    umbraco.BusinessLogic.

     

    User user = new umbraco.BusinessLogic.User(0);

     

     

    private LinqDataContext ctx;

     

     

    public Hedensted () {

     

     

    //Uncomment the following line if using designed components

     

     

    //InitializeComponent();

    }

    [

     

    WebMethod]

     

     

    public string InsertProduct(string No, string Language, string Description1, string Description2, string Amount_DKK, string Amount_EUR, int WebKategori, bool EnableOnWeb, bool DeleteOnWeb)

    {

    ctx =

     

    new LinqDataContext();

     

     

    var allProducts = (from productCategory in ctx.ContainerProductCategorys

     

     

    orderby productCategory.CategoryId ascending

     

     

    select productCategory).First();

    // string strMessage = "Done";

     

     

    return allProducts.CategoryId.ToString();

    }

     

    }

  • Thomas Hansen 2 posts 22 karma points
    Sep 16, 2010 @ 00:17
    Thomas Hansen
    0

    Problem solved...

    The problem was in the "publish" of the document types. If i choose a "sub" node at publish it + child nodes it doesn't update the XML schema for change alias names of the document types. I have to do a complete republish of the entire site from the top node.

     

    Kind regards

    \T

Please Sign in or register to post replies

Write your reply to:

Draft