More in this section

Forums / Bugs & Issues / Accessing a Shared Content Item Via User Control (VB.NET)

Accessing a Shared Content Item Via User Control (VB.NET)

5 posts, 0 answered
  1. Byzza
    Byzza avatar
    89 posts
    Registered:
    09 Jul 2007
    06 Jul 2011
    Link to this post
    So I'm not sure if this is a user problem or a bug, but I'm having a few problems getting this example: http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-modules-generic-content-querying-content-items.html to work.
    I used a couple of C# to VB converts to just make sure it was converted fine, so this is my first version of the code:

    Public Function FindGenericContent(ByVal contentItemTitle As String, ByVal contentToSearch As String) As ContentItem
        Dim manager As ContentManager = ContentManager.GetManager()
        Dim contentItem As ContentItem = manager.GetContent().Where(Function(t) t.Title = contentItemTitle).Where(Function(t) t.Status = ContentLifecycleStatus.Live).[Single]() '.Where(Function(t) t.Content.Contains(contentToSearch))
        Return contentItem
    End Function
    With this I get;
    Compiler Error Message: BC30518: Overload resolution failed because no accessible 'Where' can be called with these arguments: Extension method 'Public Function Where(predicate As System.Linq.Expressions.Expression(Of System.Func(Of Telerik.Sitefinity.GenericContent.Model.ContentItem, Integer, Boolean))) As System.Linq.IQueryable(Of Telerik.Sitefinity.GenericContent.Model.ContentItem)' defined in 'System.Linq.Queryable': Nested function does not have a signature that is compatible with delegate 'System.Func(Of Telerik.Sitefinity.GenericContent.Model.ContentItem, Integer, Boolean)'. Extension method 'Public Function Where(predicate As System.Linq.Expressions.Expression(Of System.Func(Of Telerik.Sitefinity.GenericContent.Model.ContentItem, Boolean))) As System.Linq.IQueryable(Of Telerik.Sitefinity.GenericContent.Model.ContentItem)' defined in 'System.Linq.Queryable': Overload resolution failed because no accessible '=' is most specific for these arguments: 'Public Shared Operator =(a As String, b As String) As Boolean': Not most specific. 'Public Shared Operator =(left As Telerik.Sitefinity.Model.Lstring, right As Telerik.Sitefinity.Model.Lstring) As Boolean': Not most specific. Extension method 'Public Function Where(predicate As System.Func(Of Telerik.Sitefinity.GenericContent.Model.ContentItem, Integer, Boolean)) As System.Collections.Generic.IEnumerable(Of Telerik.Sitefinity.GenericContent.Model.ContentItem)' defined in 'System.Linq.Enumerable': Nested function does not have a signature that is compatible with delegate 'System.Func(Of Telerik.Sitefinity.GenericContent.Model.ContentItem, Integer, Boolean)'. Extension method 'Public Function Where(predicate As System.Func(Of Telerik.Sitefinity.GenericContent.Model.ContentItem, Boolean)) As System.Collections.Generic.IEnumerable(Of Telerik.Sitefinity.GenericContent.Model.ContentItem)' defined in 'System.Linq.Enumerable': Overload resolution failed because no accessible '=' is most specific for these arguments: 'Public Shared Operator =(a As String, b As String) As Boolean': Not most specific. 'Public Shared Operator =(left As Telerik.Sitefinity.Model.Lstring, right As Telerik.Sitefinity.Model.Lstring) As Boolean': Not most specific. Extension method 'Public Function Where(predicate As String, ParamArray values() As Object) As System.Linq.IQueryable(Of Telerik.Sitefinity.GenericContent.Model.ContentItem)' defined in 'Telerik.Sitefinity.Data.Linq.Dynamic.DynamicQueryable': Lambda expression cannot be converted to 'String' because 'String' is not a delegate type. Extension method 'Public Function Where(filterDescriptors As System.Collections.Generic.IEnumerable(Of Telerik.Web.Data.IFilterDescriptor)) As System.Linq.IQueryable' defined in 'Telerik.Web.Data.Extensions.QueryableExtensions': Lambda expression cannot be converted to 'System.Collections.Generic.IEnumerable(Of Telerik.Web.Data.IFilterDescriptor)' because 'System.Collections.Generic.IEnumerable(Of Telerik.Web.Data.IFilterDescriptor)' is not a delegate type. Extension method 'Public Function Where(predicate As System.Linq.Expressions.Expression) As System.Linq.IQueryable' defined in 'Telerik.Web.Data.Extensions.QueryableExtensions': Lambda expression cannot be converted to 'System.Linq.Expressions.Expression' because 'System.Linq.Expressions.Expression' is not a delegate type.

    Now this isn't too much of an issue because I found this article:
    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/sdk/vb-net.aspx#1443171

    so I change t.Title to t.Title.value
    Public Function FindGenericContent(ByVal contentItemTitle As String, ByVal contentToSearch As String) As ContentItem
        Dim manager As ContentManager = ContentManager.GetManager()
        Dim contentItem As ContentItem = manager.GetContent().Where(Function(t) t.Title.Value = contentItemTitle).Where(Function(t) t.Status = ContentLifecycleStatus.Live).[Single]() '.Where(Function(t) t.Content.Contains(contentToSearch))
        Return contentItem
    End Function

    Now I get:

    Property 'System.String Value' is not defined for type 'System.String'


    I've tried a few different options on converting the title to a string first, but nothing is working.  Could you please help.

    Thank you in advance.
    Byron Boardman
  2. Byzza
    Byzza avatar
    89 posts
    Registered:
    09 Jul 2007
    08 Jul 2011
    Link to this post
    is anyone able to help with this?

    Thanks
    Regards
    Byron Boardman
  3. Teodor
    Teodor avatar
    52 posts
    Registered:
    24 Sep 2012
    11 Jul 2011
    Link to this post
    Hi Byzza,

    We are having issues with visual basic and linq expressions.  You can check here :
    http://www.telerik.com/support/pits.aspx#/public/sitefinity/4981   .

    Could you try to use something like this :

    From c In ContentManager.GetManager() where c.Title == "Test"; 

    All the best,
    Teodor
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. Byzza
    Byzza avatar
    89 posts
    Registered:
    09 Jul 2007
    13 Jul 2011
    Link to this post
    My Linq is fairly non existant at the moment, so could you help me, what should I be replacing?

    I tried both

    changing this line:
    Dim contentItem As ContentItem = manager.GetContent.Where(Function(t) t.Title.Value = contentItemTitle).Where(Function(t) t.Status = ContentLifecycleStatus.Live).[Single]()

    Too:
    Dim contentItem As ContentItem = From c In manager Where c.title = contentItemTitle

    and
    Dim contentItem As ContentItem = manager.GetContent.Where(From c In manager Where c.title = contentItemTitle).where(Function(t) t.Status = ContentLifecycleStatus.Live).[single]()


    and for both I get the error:
    Expression of type 'Telerik.Sitefinity.Modules.GenericContent.ContentManager' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider.

    Note:
    manager:
    Dim manager As ContentManager = ContentManager.GetManager()

  5. Milena
    Milena avatar
    75 posts
    Registered:
    27 Sep 2017
    18 Jul 2011
    Link to this post
    Hello Byzza,

    At the moment  we are having issues with visual basic and linq expressions. Here a PITS issue is logged : 
    http://www.telerik.com/support/pits.aspx#/public/sitefinity/4981 .

    Will need more time to investigate and fix the problem with VB.

    Sorry for inconvenience!

    Best wishes,
    Milena
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
5 posts, 0 answered