+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Telerik.Versioning.Data.DefaultProvider.GetVersion doesn't work (v3.6)

Telerik.Versioning.Data.DefaultProvider.GetVersion doesn't work (v3.6)

6 posts, 0 answered
  1. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    11 Feb 2010
    Link to this post

    Telerik.Versioning.Data.dll
    v3.6.1870.220
    DefaultProvider.GetVersion(Guid id, CultureInfo culture) has a bug in it as far as I can see.
    It only returns the latest version if there is only one version record! (Otherwise it returns zero)
    Should be: if (query.count >= 1)

    Has this been fixed in a later version?

    public override int GetVersion(Guid id, CultureInfo culture)
    {
        if (culture == null)
        {
            culture = CultureInfo.InvariantCulture;
        }
        VersionsQuery query = new VersionsQuery();
        query.Provider = this.odbProvider;
        query.AndCondition("Application", QueryCondition.EQ, this.app);
        query.AndCondition("ID", QueryCondition.EQ, id);
        query.AndCondition("CultureID", QueryCondition.EQ, culture.LCID);
        query.OrderBy = "Version DESC";
        query.LoadAll();
        if (query.Count == 1)
        {
            return query[0].Version;
        }
        return 0;
    }


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Feb 2010
    Link to this post
    Hi Andy,

    The problem is not in (query.count >= 1). It comes from  query.LoadAll() method. The bug should be fixed in the forthcoming SP that we expect to release right after Q1 of Telerik controls for ASP.NET AJAX.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    11 Feb 2010
    Link to this post
    Confused. So why the 'Order By?'
    Can you tell Nolics to do a 'Top 1' or something?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Feb 2010
    Link to this post
    Hi Andy,

    "Order by" is used, because the method should return the last version of the item, but the problem is not there as written in the other post.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    11 Feb 2010
    Link to this post
    Yes, that's pretty obvious, but that's not what I asked.

    I assume you need to amend the query to do a 'Top 1' result (which would work together with the OrderBy) but I don't know how to tell Nolics to do this.

    I am writing a workaround, but it would be helpful to know the code you intend to use, as it would advance my understanding of the Nolics engine (even though it will eventually be deprecated).

    Thanks,
    Andy
  6. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    11 Feb 2010
    Link to this post
    I have worked around this (in a longer-winded way) using VersionManager.GetItems(), based on the code:

    IList versions = VersionManager.GetItems(libraryDocument.ID, null);                   
     
    if (versions != null && versions.Count >= 1)
        latestVersion = ((IVersionItem)versions[0]).Version;               
    else
        latestVersion = 0;           

    ...wrapped into functions and with a few more defensive checks in!

    Thanks for your time Ivan.
    Cheers!
    Andy
Register for webinar
6 posts, 0 answered