Copied to clipboard

Flag this post as spam?

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


  • patrick 41 posts 93 karma points
    Dec 03, 2013 @ 15:29
    patrick
    0

    System.Collections.Generic.List<umbraco.cms.businesslogic.media.Media>' does not contain a definition for 'First'

    I'm having a brain freeze for the error, generating in the following code;

    It seems that:

    var firstImageUrl = images.First();

    Goes wrong because the Extension Method First (LINQ) cant be found.
    Anyone?


    @inherits umbraco.MacroEngines.DynamicNodeContext 
    @using umbraco.MacroEngines;
    @using System.Linq;
    @using System.Xml.Linq
    @using umbraco.cms.businesslogic.media;
    @{
        var csv = uQuery.GetCurrentNode().GetProperty<string>("articleImages");
        var images = uQuery.GetMediaByCsv(Model.articleImages);
       
        var firstImageUrl = images.First();
        var urlMediumFirst = String.Format("/ImageGen.ashx?image={0}&width=300&height=300&constrain=true",firstImageUrl);
       
        <div id="imageGallery">
            <div id="imageGalleryPlaceHolder"><div id="imageGalleryContent"><img id="mainProductImage"  src="@urlMediumFirst" border="0"/></div></div>
            <div id="imageGalleryButtons">
                @foreach (Media img in images)
                {
                    var imageUrl = img.GetImageUrl();
                    var urlMedium = String.Format("/ImageGen.ashx?image={0}&width=300&height=300&constrain=true",imageUrl);
                    var urlSmall = String.Format("/ImageGen.ashx?image={0}&width=50&height=50&constrain=true",imageUrl);
                       
                    <a href="#" rel="@urlMedium" class="galleryImage"><img  src="@urlSmall" border="0"/></a>
                }
            </div>
        </div>
    }

     

     

  • patrick 41 posts 93 karma points
    Dec 03, 2013 @ 15:36
    patrick
    100

    Ahhh the keyword is "Dynamic" I had to cast the object first:

    var images = uQuery.GetMediaByCsv(Model.articleImages) as IEnumerable<Media>;

     

Please Sign in or register to post replies

Write your reply to:

Draft