Copied to clipboard

Flag this post as spam?

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


  • GP 16 posts 46 karma points
    Mar 03, 2013 @ 13:59
    GP
    0

    How to do a Join In Umbraco

    Hi, 

    is ti possible to do a join in umbraco and get something like a DataTable in return?

    I have three types of docs  named "Product" (name, description, color, height …), "Company" (name, location logo …) and "OfferForSale".  The last one is composed of "quantity"  and two "ultimate  content picker datatype". One is  named "Product" that points to a node filled with Products and Company that points to a node filled with (imagine) Companies. An instance of a doc type "OfferForSale" could be for example (quantity ="23",Company ="Nestle", Product="KitKat")

    Now what I want is to get all "OfferForSale" published, for example made by company called "Nestle", including all the information about the products being offered. I would expect an object like a DataTable where for each row I can find all the information regarding the products and the offerforsale.

    My goal is to bind the result of the query with the GridView.

     

    The only thing that I can think of right now is  this:  use the Method GetNodesByXPath to obtain all offers made by "Nestle" and then  bind it to the grid. In the event  RowDataBound retrieve the data regarding the product by  using the id that is in OfferForSale item being bound.

     

    thank you

     

    Gian Paolo

     

     

     

  • Charles Afford 1163 posts 1709 karma points
    Mar 03, 2013 @ 16:04
    Charles Afford
    0

    Hey, can i ask what the is result you want is, what you want to do with it, the structure of your content tree and the language you are using?  You should be able to aggrigrate this data into a model somehow :).

  • GP 16 posts 46 karma points
    Mar 04, 2013 @ 23:16
    GP
    0

    I'm building a  User Control macro using c#. I want to bind the result of the query to a GridView. Every company from the front-end is going to upload a CSV file with their offers. Each row will be composed of several information about the products plus the quantities. What I've done to avoid to import the some product more than one I cerated on document type named "Prodcut", one document type named "OfferForSale"  and one colled Company. "Product" is composed of all the information about the product, "Company"  with information about the company and "OfferForSale" is like a Relationship Table among the "Product" and "Company" docs types. The DataType i've used for this is the ultimate content picker.  The content tree has three node:  "CompaniesList" which contains  only docs of type "Company", ProductsList which contains only doc types of Product and "OfferForSalesList" wich contains only doc type "OfferForSale". 

    is it possible to join in some way OfferForSalesList with ProductsList and CompaniesList ? as if they were 3 tables.

  • Charles Afford 1163 posts 1709 karma points
    Mar 10, 2013 @ 10:32
    Charles Afford
    0

    Hey sorry did not realise this had been updated.  Just reading what you wrote :)

  • Charles Afford 1163 posts 1709 karma points
    Mar 10, 2013 @ 10:38
    Charles Afford
    0

    I think you want to look at it in a content structure from your content tree rather than a database.

    Can i ask what your ultimate goal is, that is how do you want to render on the page and where is this data currently being stored (I am assuming nodes within the content tree)??

    Charlie :)

  • Andreas Iseli 150 posts 427 karma points
    Mar 10, 2013 @ 11:46
    Andreas Iseli
    0

    I've not tested how fast this is, but you could try the IContent.GetDescendents() method on the top node using LINQ to filter them by the document type. Then you have one enumerable containing all required items.

  • Charles Afford 1163 posts 1709 karma points
    Mar 10, 2013 @ 14:58
    Charles Afford
    0

    Yea, the idea is to get the items into an Ienum that you can iterate through, i was suggesting using a model becuase it will enable you to abstract some of the bussiness logic outside of your view

  • GP 16 posts 46 karma points
    Mar 10, 2013 @ 18:15
    GP
    0

    I'm not sure what you mean by "my ultimate goal" but what I need to do is to create a table report  rendered by a GrirdView in a user control macro. Yes the data are stored in the content tree.  I think you've got me the idea. Thank you guys for helping me out..

    GP

  • Charles Afford 1163 posts 1709 karma points
    Mar 10, 2013 @ 18:21
    Charles Afford
    0

    Hi, glad you have found a workable solution :).  When i refer to ultimate goal i mean, when everything is completed what page do you want to have and what data do you want on that page.  When you know that you can work out where to put then data and then how to get that data from that sorce.  Charlie :)

Please Sign in or register to post replies

Write your reply to:

Draft