More in this section
Forums / Developing with Sitefinity / What 'using' needed when I used CreateRelation method (in DynamicContent class)

What 'using' needed when I used CreateRelation method (in DynamicContent class)

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
3 posts, 0 answered
  1. test
    test avatar
    4 posts
    Registered:
    24 Jun 2016
    29 Aug 2016
    Link to this post

    Hello everyone,

    I have a problem when using CreateRelation method (in CreateRelation  class,) what is missing 'using' ?

    Regards,

    Eddy

    my code:

    ...
    using Telerik.Sitefinity;
    using Telerik.Sitefinity.Model;
    using Telerik.Sitefinity.DynamicModules;
    using Telerik.Sitefinity.Data.Linq.Dynamic;
    using Telerik.Sitefinity.DynamicModules.Model;
    using Telerik.Sitefinity.GenericContent.Model;
    using Telerik.Sitefinity.Utilities.TypeConverters;
    using Telerik.Sitefinity.Security;
    using Telerik.Sitefinity.Lifecycle;
    using Telerik.Sitefinity.Modules.Libraries;

    namespace SitefinityWebApp
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {

            }

            // Demonstrates how a collection of Products can be retrieved
            public IQueryable<DynamicContent> RetrieveCollectionOfProducts()
            {
    ...
            }

            // Creates a new product item
            private void CreateProductItem(DynamicModuleManager dynamicModuleManager, Type productType)
            {

    ...
                DynamicContent productItem = dynamicModuleManager.CreateDataItem(productType);
    ...

                LibrariesManager imageManager = LibrariesManager.GetManager();
                var imageItem = imageManager.GetImages().FirstOrDefault(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master);
                if (imageItem != null)
                {
                    // This is how we relate an item
                    productItem.CreateRelation(imageItem, "image");
                }

    ...

  2. Victor Leontyev
    Victor Leontyev avatar
    65 posts
    Registered:
    01 Jul 2014
    29 Aug 2016 in reply to test
    Link to this post

    Hi Eddy. You need to add

    using Telerik.Sitefinity.RelatedData;

     

  3. test
    test avatar
    4 posts
    Registered:
    24 Jun 2016
    29 Aug 2016 in reply to Victor Leontyev
    Link to this post

    Hi Victor,

    Thanks for your help..

    Regards,

    Eddy

3 posts, 0 answered