Print Page | Close Window

XtraGrid LinqServerMode

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1579
Printed Date: 23-Sep-2018 at 7:40pm


Topic: XtraGrid LinqServerMode
Posted By: erturkcevik
Subject: XtraGrid LinqServerMode
Date Posted: 08-Dec-2009 at 1:29pm
Hi,
When the XtraGrid control operates in http://www.devexpress.com/Help/Content.aspx?help=XtraGrid&document=CustomDocument2991.htm - server mode , it delegates all data processing to the server, and loads only records to be displayed on screen. This allows you to dramatically increase performance against large datasets
Can I binding entity data to DevExpress XtraGrid at LinqServeMode ?
 
 
Best Regards,



Replies:
Posted By: davidklitzke
Date Posted: 08-Dec-2009 at 3:23pm

Have you looked at the requested DevEx feature personally? It appears to be inextricably tied to DevEx’s proprietary data access technology, XPO; specifically it requires an implementer of DevExpress.Data.IListServer.

You may safely assume that we have no intention of integrating with XPO.   We will not support this IListServer interface or the ServerMode option. You are welcome to try to implement it yourself.  You can implement the IListServer interface using DevForce as the storage proxy in place of DevEx’s proprietary, 2-tier, cacheless XPO.



Posted By: erturkcevik
Date Posted: 09-Dec-2009 at 11:43am
< = =text/> //
  < id=1 method=post name=1 =ViewSource.aspx?Id=cd827f53-7e67-46d4-badc-fc2a0ce9de30&showJS=false>
Can I using this solulation with DevForce EF?
 
Regards,
 
 

This simple IListServer interface implementation is made to illustrate the interface members: what data is passed in arguments, and what result these members are expected to produce. Only essential interface members are implemented.

 
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Collections;
using DevExpress.Data;
using DevExpress.Data.Filtering;
using DevExpress.Data.Filtering.Helpers;

namespace DevExpress.Sample
{
    public class SimpleServerModeDataSource: IListServer
    {
        Type objectType;
        PropertyDescriptor pdKey;

        ArrayList storage; //hoax
        ArrayList storageProxy;
        Hashtable groups;
        Dictionary<object, object> totals;

        CriteriaOperator filter;
        ListSortDescriptionCollection sortInfo;
        int groupCount;
        List<ListSourceSummaryItem> summaryInfo;
        List<ListSourceSummaryItem> totalSummaryInfo;


        public SimpleServerModeDataSource(Type objectType, string keyProperty, ICollection data)
            :this(objectType, keyProperty)
        {
            storage.AddRange(data);
            ProcessCollection();
        }

        public SimpleServerModeDataSource(Type objectType, string keyProperty)
        {
            this.objectType = objectType;
            PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(objectType);
            pdKey = pdc[keyProperty];

            storage = new ArrayList();
            storageProxy = new ArrayList();
            groups = new Hashtable();
            totals = new Dictionary<object, object>();
        }

        private void SummaryCollect(Dictionary<object, object> dict, List<ListSourceSummaryItem> info, object obj)
        {
            if (info == null || dict == null) return;
            foreach (ListSourceSummaryItem item in info)
            {
                decimal acc = 0;
                try
                {
                    acc = Convert.ToDecimal(dict[item.Key]);
                }
                catch { }
                if (item.SummaryType == SummaryItemType.Count)
                {
                    acc++;
                }
                else
                {
                    decimal v = 0;
                    try
                    {
                        v = Convert.ToDecimal(item.Descriptor.GetValue(obj));
                    }
                    catch { }
                    switch (item.SummaryType)
                    {
                        case SummaryItemType.Sum:
                            acc += v;
                            break;
                    }
                }
                dict[item.Key] = acc;
            }
        }

        private void SummarySetUp(Dictionary<object, object> dict, List<ListSourceSummaryItem> info)
        {
            if (info == null || dict == null) return;
            dict.Clear();
            foreach (ListSourceSummaryItem item in info)
            {
                dict.Add(item.Key, 0);
            }
        }

        private void ProcessCollection()
        {
            PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(objectType);
            ExpressionEvaluator evaluator = new ExpressionEvaluator(pdc, filter);
            storageProxy.Clear();
            SummarySetUp(totals, totalSummaryInfo);
            foreach (object o in storage)
            {
                if (evaluator.Fit(o))
                {
                    storageProxy.Add(o);
                    SummaryCollect(totals, totalSummaryInfo, o);
                }
            }
            if (sortInfo != null)
            {
                storageProxy.Sort(new SimpleComparer(sortInfo));
            }
            groups.Clear();
        }

        #region IListServer Members

        public void ApplySort(ListSortDescriptionCollection sortInfo, int groupCount, List<ListSourceSummaryItem> summaryInfo, List<ListSourceSummaryItem> totalSummaryInfo)
        {
            this.sortInfo = sortInfo;
            this.groupCount = groupCount;
            this.summaryInfo = summaryInfo;
            this.totalSummaryInfo = totalSummaryInfo;
            ProcessCollection();
        }

        public CriteriaOperator FilterCriteria
        {
            get
            {
                return filter;
            }
            set
            {
                if (Equals(filter, value)) return;
                filter = value;
                ProcessCollection();
            }
        }

        public int FindIncremental(PropertyDescriptor column, string value, int startIndex, bool searchUp)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public object FindKeyByBeginWith(PropertyDescriptor column, string value)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public object FindKeyByValue(PropertyDescriptor column, object value)
        {
            foreach (object o in storageProxy)
            {
                if (Equals(column.GetValue(o), value))
                    return pdKey.GetValue(o);
            }
            return null;
        }

        public List<ListSourceGroupInfo> GetGroupInfo(ListSourceGroupInfo parentGroup)
        {
            List<ListSourceGroupInfo> rows = new List<ListSourceGroupInfo>();
            ArrayList uniqueValues = new ArrayList();
            int level = (parentGroup == null) ? 0 : (parentGroup.Level + 1);
            PropertyDescriptor pd = sortInfo[level].PropertyDescriptor;
            foreach (object o in storageProxy)
            {
                ListSourceGroupInfo group = parentGroup;
                while (group != null)
                {
                    System.Diagnostics.Debug.Assert((group.Level == 0) || groups[group] != null);
                    object fv = sortInfo[group.Level].PropertyDescriptor.GetValue(o);
                    if (!Equals(fv, group.GroupValue)) goto Skip;
                    group = (ListSourceGroupInfo)groups[group];
                }
                object v = pd.GetValue(o);
                ListSourceGroupInfo info;
                int index = uniqueValues.IndexOf(v);
                if (index < 0)
                {
                    uniqueValues.Add(v);
                    info = new SimpleListSourceGroupInfo();
                    info.GroupValue = v;
                    info.Level = level;
                    SummarySetUp(info.Summary, summaryInfo);
                    rows.Add(info);
                    groups.Add(info, parentGroup);
                }
                else
                {
                    info = rows[index];
                }
                info.ChildDataRowCount++;
                SummaryCollect(info.Summary, summaryInfo, o);
                Skip:;
            }
            return rows;
        }

        public int GetRowIndexByKey(object key)
        {
            for (int i = 0; i < storageProxy.Count; i++)
            {
                if (Equals(pdKey.GetValue(storageProxy[i]), key))
                    return i;
            }
            return -1;
        }

        public object GetRowKey(int index)
        {
            return pdKey.GetValue(this[index]);
        }

        public Dictionary<object, object> GetTotalSummary()
        {
            return totals;
        }

        public object[] GetUniqueColumnValues(PropertyDescriptor descriptor, int maxCount, bool includeFilteredOut, bool roundDataTime)
        {
            ArrayList uniqueValues = new ArrayList();
            IList list = includeFilteredOut ? storage : storageProxy;
            foreach (object o in list)
            {
                object v = descriptor.GetValue(o);
                int index = uniqueValues.IndexOf(v);
                if (index < 0)
                {
                    uniqueValues.Add(v);
                    if (maxCount > 0 && uniqueValues.Count >= maxCount)
                        break;
                }
            }
            return uniqueValues.ToArray();
        }

        #endregion

        #region IList Members

        public int Add(object value)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void Clear()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public bool Contains(object value)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public int IndexOf(object value)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void Insert(int index, object value)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public bool IsFixedSize
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public bool IsReadOnly
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public void Remove(object value)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void RemoveAt(int index)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public object this[int index]
        {
            get
            {
                return storageProxy[index];
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        #endregion

        #region ICollection Members

        public void CopyTo(Array array, int index)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public int Count
        {
            get { return storageProxy.Count; }
        }

        public bool IsSynchronized
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public object SyncRoot
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        #endregion

        #region IEnumerable Members

        public IEnumerator GetEnumerator()
        {
            return storageProxy.GetEnumerator();
        }

        #endregion
    }

    class SimpleListSourceGroupInfo : ListSourceGroupInfo
    {
        private Dictionary<object, object> summary;
        public override Dictionary<object, object> Summary
        {
            get { return summary; }
        }
        public SimpleListSourceGroupInfo()
        {
            summary = new Dictionary<object, object>();
        }
    }

    class SimpleComparer : IComparer
    {
        ListSortDescriptionCollection sortInfo;

        public SimpleComparer(ListSortDescriptionCollection sortInfo)
        {
            this.sortInfo = sortInfo;
        }

        #region IComparer Members

        public int Compare(object x, object y)
        {
            foreach (ListSortDescription info in sortInfo)
            {
                object xx = info.PropertyDescriptor.GetValue(x);
                object yy = info.PropertyDescriptor.GetValue(y);
                int sign = Comparer.Default.Compare(xx, yy);
                if (sign != 0)
                    return (info.SortDirection == ListSortDirection.Ascending) ? sign : -sign;
            }
            return 0;
        }

        #endregion
    }
}
//.name == "cd827f53-7e67-46d4-badc-fc2a0ce9de30") { iFrames.style.visibility = "visible"; } } } //]]>


Posted By: WardBell
Date Posted: 09-Dec-2009 at 11:15pm
This looks like an example provided by Developer Express itself. It is an empty shell that doesn't do anything ... it's a mock ... or so it seemed to me when I first read it awhile ago. It may be a good guide for writing your own implementation but it isn't sufficient to page DevForce data in as written ... which is what I think you are looking to do.
 
IdeaBlade will not be supporting this interface. We assist only with populating Windows Forms and with data binding of controls to data sources. We leave it to you to determine how the objects get into those data sources.
 
I encourage you to implement the IListServer interface using DevForce on your own. I'd love to hear from you when you have done so, especially if you are willing to share the results with others in the DevForce community.


Posted By: erturkcevik
Date Posted: 11-Dec-2009 at 2:34pm
Thank you for reply
What can I do improve performance with working large data? How can I improve data binding performance?
Please say me methots of the Devforce EF.
 
Regards,
 


Posted By: erturkcevik
Date Posted: 13-Dec-2009 at 11:01am
DevExpress Says :
 
Thank you for the suggestion. I'm afraid that we have to decline it. The LinqServerModeSource can be associated with any queryable source, i.e. the data source should implement the IQueryable interface. We aren't going to support the Server Mode for other data source type, sorry.

Thanks,
Uriah.



Posted By: WardBell
Date Posted: 14-Dec-2009 at 5:59pm
DevForce 2009 (our LINQ version) supports IQueryable and could be a basis for building your own implementation.

We are also considering development of a self-paging collection. "Considering" ... not doing.  I have some ideas about how that might work which I intend to prototype if I get the time.
 
Sorry I can't commit to more right now.


Posted By: erturkcevik
Date Posted: 15-Dec-2009 at 10:50am
Thank you for answers. I think performance important for working large dataset
and  I recommend, you adding feature of the "delayed load data" or bindable paging data to Devforce as soon as.
This features existing standart  of the Devforce.
 
Regards,
 


Posted By: Thinkly
Date Posted: 25-Feb-2010 at 1:34am
http://blogs.msdn.com/astoriateam/archive/2008/12/15/design-notes-row-count.aspx -
I am a user of DevExpress and I planned to evaluate DevForce.
 
I am dealing with large data and so I use Server Mode of DevExpress. When I found this discuss, I think I should evaluate DevForce later.
 
According to the discuss, it seems it is easy to offer a solution by DevForce. I have no idea of the implementation of DevForce. If DevForce is based on ADO.net data services,  there could be some troubles.
 
Although MS offers count function now (http://blogs.msdn.com/astoriateam/archive/2008/12/15/design-notes-row-count.aspx), but it lacks other summary functions. It could let the Server Mode very limited.
 
I expect IdealBlade has a better solution.
 
 
 
 
 
 



Print Page | Close Window