Large volume data loading with Nhibernate + Windows Forms

Asked

Viewed 247 times

0

I use the ORM Nhibernate in a windows Forms project and there is a forecast to work with a large volume of data in several tables, ranging from 1 to 15 thousand records on average. Although it is not as large a volume of data as some may say, this compromising the performance of the application when it is necessary to popular a Datagridview with a complete listing of one of these tables.

My doubts are as follows:

  1. How best to upload ALL this data?
  2. How to popular Datagridview when creating a form without a Delay occurring on its opening?
  3. Has anyone ever used Nhibernate with Reactive?

1 answer

1


What is the best way to upload ALL this data? How to popular Datagridview when creating a form without a Delay occurring on its opening?

Paginando a Datagridview. This answer of the SO gringo 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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.