Reverse Mapping With ORM Performance issue.

5 posts, 1 answers
  1. Mandy
    Mandy avatar
    33 posts
    Member since:
    Mar 2010

    Posted 11 May 2011 Link to this post

    Hello Admin,

                       i am using Reverse Mapping With ORM and it creates no issue while we develop application. But now we make our site ready for production but found some Performance issue. All Radgrid takes so much time while we do simple operations like inserting,updating and Deleting data from grid.

    we had another site which using client side binding using web-service.Is there is any way to use this kind of approach in this also as it gives us a better performance.

    Or is there is any other way to remove this performance issue.

    Please suggest us ASAP.


    Thanks,
    Mandeep Singh
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 13 May 2011 Link to this post

    Hi Mandeep Singh,

    Unfortunately the information you have provided us is by far not enough to identify possible problems in your application. I believe the best starting point for you would be to identify the possible bottlenecks in your application and confirm if they are indeed connected with OpenAccess or perhaps the problems lies elsewhere.
    Depending on your project it might be possible to use wcf services but that is entirely depending on your project and requirements.

    Kind regards,
    Petar
    the Telerik team
    Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
  3. DevCraft banner
  4. Mandy
    Mandy avatar
    33 posts
    Member since:
    Mar 2010

    Posted 23 May 2011 Link to this post

    Hello Admin,

    Thanks for the reply, 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;
                sortExpression.Add(item);
            }

            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);
                }
                else
                {
                    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;
        }


        #endregion


     
    Please post the reply asap....


    Thanks,
    Mandeep Singh
  5. Mandy
    Mandy avatar
    33 posts
    Member since:
    Mar 2010

    Posted 23 May 2011 Link to this post

    Hi,

    Anyone who can help me on this topic... ASAP.


    Thanks in Advance,,,

    Mandeep Singh
  6. Answer
    Veli
    Admin
    Veli avatar
    2002 posts

    Posted 26 May 2011 Link to this post

    Hello Mandeep,

    We are unable to identify the exact cause of this issue from the source code you provided. However, the exception you are getting, or, more accurately, TypeDescriptor.GetProperties() returning null, may indicate  that the type you have specified in your generic parameter (ProjectUserMapping in your case) does not have a property with a name specified by the FieldName value of the GridSortExpression. You may want to check whether the SortExpression instance passed in the constructor to the GridGenericSorter<T> specifies a FieldName that corresponds to a public property of type T.

    Veli
    the Telerik team

    Consider using RadControls for ASP.NET AJAX (built on top of the ASP.NET AJAX framework) as a replacement for the Telerik ASP.NET Classic controls, See the product support lifecycle here.

Back to Top
DevCraft banner