Exemplo n.º 1
0
        public override VirtualDataTable FilterData(string newDataName, string rowFilter)
        {
            if (string.IsNullOrEmpty(rowFilter))
            {
                return(new TAdoDotNetDataTable(newDataName, this, Data, false));
            }

            DataTable FilteredData = null;

            try
            {
                DataView dv = new DataView(Data, rowFilter, String.Empty, DataViewRowState.CurrentRows);
                try
                {
                    FilteredData = Data.Clone();  //create a copy of the filtered data.
                    foreach (DataRowView rv in dv)
                    {
                        FilteredData.ImportRow(rv.Row);
                    }
                }
                finally
                {
                    TCompactFramework.DisposeDataView(dv);
                }
                return(new TAdoDotNetDataTable(newDataName, this, FilteredData, true, OriginalTable));
            }
            catch
            {
                if (FilteredData != null)
                {
                    TCompactFramework.DisposeDataTable(FilteredData);
                }
                throw;
            }
        }
Exemplo n.º 2
0
        protected override void Dispose(bool disposing)
        {
            try
            {
                //only managed resources
                if (disposing)
                {
                    if (DataNeedsDispose && Data != null)
                    {
                        TCompactFramework.DisposeDataTable(Data);
                    }
                    Data = null;

                    foreach (TLookupCache dv in LookupDataViews.Values)
                    {
                        dv.Dispose();
                    }
                    LookupDataViews = null;
                }
            }
            finally
            {
                //last call.
                base.Dispose(disposing);
            }
        }
Exemplo n.º 3
0
 protected override void Dispose(bool disposing)
 {
     try
     {
         if (disposing)
         {
             if (SourceForFilteredData != null)
             {
                 TCompactFramework.DisposeDataView(SourceForFilteredData);
             }
             SourceForFilteredData = null;
             if (SortedFilteredData != null)
             {
                 TCompactFramework.DisposeDataView(SortedFilteredData);
             }
             SortedFilteredData = null;
             if (FilteredData != null && FilteredDataNeedsDispose)
             {
                 TCompactFramework.DisposeDataTable(FilteredData);
             }
             FilteredData = null;
         }
     }
     finally
     {
         //last call.
         base.Dispose(disposing);
     }
 }
Exemplo n.º 4
0
        public override VirtualDataTable GetDistinct(string newDataName, int[] filterFields)
        {
            DataColumn[] SortFields = GetSortFields(Data, filterFields);

#if (FRAMEWORK20)
            if (Data.CaseSensitive)  //this does not seem to work on non case sensitives
            {
                DataTable NewData20 = null;
                try
                {
                    DataView dv = new DataView(Data);
                    try
                    {
                        string[] Columns = new string[SortFields.Length];
                        for (int i = 0; i < Columns.Length; i++)
                        {
                            Columns[i] = SortFields[i].ColumnName;
                        }
                        NewData20 = dv.ToTable(Data.TableName, true, Columns);
                    }
                    finally
                    {
                        TCompactFramework.DisposeDataView(dv);
                    }

                    return(new TAdoDotNetDataTable(newDataName, this, NewData20, true, OriginalTable));
                }
                catch
                {
                    TCompactFramework.DisposeDataTable(NewData20);
                    throw;
                }
            }
#endif
            string    Sort    = GetSortString(SortFields);
            DataTable NewData = new DataTable();
            try
            {
                NewData.Locale        = Data.Locale;
                NewData.CaseSensitive = Data.CaseSensitive;

                CopyColumns(SortFields, NewData);
                DataView dv = new DataView(Data, String.Empty, Sort, DataViewRowState.CurrentRows);
                try
                {
                    object[] LastRow = null;

                    NewData.BeginLoadData();
                    foreach (DataRowView dr in dv)
                    {
                        CopyRow(SortFields, dr, NewData, ref LastRow);
                    }
                    NewData.EndLoadData();
                }
                finally
                {
                    TCompactFramework.DisposeDataView(dv);
                }
                return(new TAdoDotNetDataTable(newDataName, this, NewData, true, OriginalTable));
            }
            catch
            {
                TCompactFramework.DisposeDataTable(NewData);
                throw;
            }
        }