High volume data loading with NHibernate + Windows Forms

0

I use ORM NHibernate in a windows forms project and there is a forecast of working with a large volume of data across multiple tables, ranging from 1 to 15 thousand records on average. Although not as large a volume of data as some may say, this is compromising application performance when it is necessary to populate a DataGridView with a complete listing of one of these tables.

My doubts are as follows:

  • What is the best way to load ALL of these data?
  • How popular is the DataGridView when creating a form without a Delay opening?
  • Has anyone ever used Nhibernate with Reactive?
  • asked by anonymous 07.05.2014 / 17:26

    1 answer

    1

    What is the best way to load ALL of these data? How do I use the DataGridView when creating a form without a Delay in its opening?

    Paging the DataGridView. This answer of the gringo OS has an example which I reproduce translated below:

    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;
    
    namespace ExemploPaginacao
    {
        public partial class Form1 : Form
        {
            private const int totalRegistros = 15000;
            private const int tamanhoPagina = 50;
    
            public Form1()
            {
                InitializeComponent();
                dataGridView1.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "Index" });
                bindingNavigator1.BindingSource = bindingSource1;
                bindingSource1.CurrentChanged += new System.EventHandler(bindingSource1_CurrentChanged);
                bindingSource1.DataSource = new ListaPaginada();
            }
    
            private void bindingSource1_CurrentChanged(object sender, EventArgs e)
            {
                // Este evento prepara um novo conjunto de registros quando o Current (propriedade que indica o registro atual da Grid é mudado
                int deslocamento = (int)bindingSource1.Current;
                var registros = new List<Registro>();
                for (int i = deslocamento; i < deslocamento + tamanhoPagina && i < totalRegistros; i++)
                    registros.Add(new Registro { Index = i });
                dataGridView1.DataSource = registros;
            }
    
            class Registro
            {
                public int Index { get; set; }
            }
    
            class ListaPaginada: System.ComponentModel.IListSource
            {
                public bool ContemColecaoDeListas { get; protected set; }
    
                public System.Collections.IList GetList()
                {
                    // Retorna uma lista de deslocamentos de página baseada em "totalRegistros" and "tamanhoPagina"
                    var deslocamentosPaginas = new List<int>();
                    for (int deslocamento = 0; deslocamento < totalRegistros; deslocamento += tamanhoPagina)
                        deslocamentosPaginas.Add(deslocamento);
                    return deslocamentosPaginas;
                }
            }
        }
    }
    

    Has anyone ever used Nhibernate with Reactive?

    Can you improve this part of the question? This part is based on opinions and does not fit a good answer, therefore.

        
    07.05.2014 / 18:06