Client side binding using ORM with normal WebService but PropertyDescriptor _descriptor is always null

Thread is closed for posting
2 posts, 0 answers
  1. Mandy
    Mandy avatar
    33 posts
    Member since:
    Mar 2010

    Posted 24 May 2011 Link to this post

    Hello Admin,

      i had used the client side binding using ORM with normal WebService , but i am keep getting the error when i trying to sort the grid , the grid bind successfully and paging also works fine but the sorting gives me error of object reference not set to instance of an object. i tried to debug and found that the PropertyDescriptor _descriptor = null; is always null .i had used reverse mapping of ORM and maps the two different tables. below is my code ..

    [WebMethod(EnableSession = true)]
        public List<ProjectUserMapping> GetData(int startRowIndex, int maximumRows, string SortField, GridSortOrder SortOrder)
            List<GridSortExpression> sortExpression = new List<GridSortExpression>();
            if (SortField != "")
                GridSortExpression item = new GridSortExpression();
                item.FieldName = SortField.ToString();
                item.SortOrder = SortOrder;

            IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope();

            //var query = scope.Extent<ProjectUserMapping>().ToList();
            var result = from o in scope.Extent<ProjectUserMapping>()
                         where o.UserId.Equals(Convert.ToInt32(Session["UserId"]))
                         select o;
            var query = result.ToList();
            List<ProjectUserMapping> list = new List<ProjectUserMapping>();
            list = query;
            ///Getting Paging and sorting
            list = GetProjectsPagingAndSorting(list, startRowIndex, maximumRows, sortExpression); 
            return list;

    #region Sorting Paging

        public class GridGenericSorter<T> : IComparer<T>
            GridSortExpression _expression = null;
            PropertyDescriptor _descriptor = null;

            public GridGenericSorter(GridSortExpression expression)
                _descriptor = TypeDescriptor.GetProperties(GetType().GetGenericArguments()[0]).Find(expression.FieldName, true);
                _expression = expression;

            public int Compare(T o1, T o2)
                IComparable comparable1 = (IComparable)_descriptor.GetValue(o1);
                IComparable comparable2 = (IComparable)_descriptor.GetValue(o2);

                if (_expression.SortOrder == GridSortOrder.Ascending)
                    return comparable1.CompareTo(comparable2);
                    return comparable2.CompareTo(comparable1);

        /// <summary>
        /// Getting Project paging and Sorting
        /// </summary>
        /// <param name="data"></param>
        /// <param name="startRowIndex"></param>
        /// <param name="maximumRows"></param>
        /// <param name="sortExpression"></param>
        /// <returns></returns>
        public static List<ProjectUserMapping> GetProjectsPagingAndSorting(List<ProjectUserMapping> data, int startRowIndex, int maximumRows, List<GridSortExpression> sortExpression)
            if (sortExpression.Count > 0)
                foreach (GridSortExpression expression in sortExpression)
                    data.Sort(new GridGenericSorter<ProjectUserMapping>(expression));
            List<ProjectUserMapping> list = new List<ProjectUserMapping>();
            startRowIndex = startRowIndex >= data.Count ? 0 : startRowIndex;
            decimal Count = data.Count - startRowIndex;
            for (int i = 0; i < Math.Min(maximumRows, Count); i++)
                list.Add(data[i + startRowIndex]);
            return list;


    Please post the reply asap....

    Mandeep Singh
  2. Damyan Bogoev
    Damyan Bogoev avatar
    581 posts

    Posted 26 May 2011 Link to this post

    Hi Mandeep Singh,

    Could you please provide us with a sample application that demonstrates the wrong behavior in order to investigate the cause for the error further?
    I have changed the thread type to Product Feedback in order to enable file attachments.
    We are looking forward to hearing from you.

    Damyan Bogoev
    the Telerik team
    Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
Back to Top