Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

What is the best way to bind data in ListView?

$
0
0

Hello!

I'm using SQLite with Xamarin.Forms and I need to binding a huge data into a listview, It's almost 16.000 register.

What is the best way to do this? Using IEnumerable, ObservableCollection, List?

What is the best way to use ItemTemplate, create a class, inherited with ViewCell, or using XAML?

This is my model:

`[Table("tbPROD")]
public class E_PROD : EntidadeBase, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this,
new PropertyChangedEventArgs(propertyName));
}

    //

    #region Atributos

    private string _PROD_Id = string.Empty;
    private string _PROD_Codigo = string.Empty;
    private int _PROD_SQEM_Id = 0;
    private string _PROD_Descricao = string.Empty;
    private string _PROD_UnidadeVenda = string.Empty;
    private string _PROD_UnidadeEstoque = string.Empty;
    private int _PROD_Ordem = 0;
    private decimal _PROD_Valor = 0;

    #endregion

    #region Propriedades

    [PrimaryKey]
    public string PROD_Id
    {
        get
        {
            return _PROD_Id;
        }

        set
        {
            _PROD_Id = value;
            OnPropertyChanged(nameof(PROD_Id));
        }
    }

    [NotNull]
    [Default(false, "")]
    [MaxLength(15)]
    public string PROD_Codigo
    {
        get
        {
            return _PROD_Codigo;
        }
        set
        {
            _PROD_Codigo = value;
            OnPropertyChanged(nameof(PROD_Codigo));
        }
    }

    [NotNull]
    [Default(false, 0)]
    public int PROD_SQEM_Id
    {
        get
        {
            return _PROD_SQEM_Id;
        }

        set
        {
            _PROD_SQEM_Id = value;
            OnPropertyChanged(nameof(PROD_SQEM_Id));
        }
    }

    [MaxLength(40)]
    [NotNull]
    [Default(false, "")]
    public string PROD_Descricao
    {
        get
        {
            return _PROD_Descricao;
        }
        set
        {
            _PROD_Descricao = value;
            OnPropertyChanged(nameof(PROD_Descricao));
        }
    }

    [MaxLength(3)]
    [NotNull]
    [Default(false, "")]
    public string PROD_UnidadeVenda
    {
        get
        {
            return _PROD_UnidadeVenda;
        }
        set
        {
            _PROD_UnidadeVenda = value;
            OnPropertyChanged(nameof(PROD_UnidadeVenda));
        }
    }

    [MaxLength(3)]
    [NotNull]
    [Default(false, "")]
    public string PROD_UnidadeEstoque
    {
        get
        {
            return _PROD_UnidadeEstoque;
        }
        set
        {
            _PROD_UnidadeEstoque = value;
            OnPropertyChanged(nameof(PROD_UnidadeEstoque));
        }
    }

    [NotNull]
    [Default(false, 0)]
    public int PROD_Ordem
    {
        get
        {
            return _PROD_Ordem;
        }

        set
        {
            _PROD_Ordem = value;
            OnPropertyChanged(nameof(PROD_Ordem));
        }
    }

    public decimal PROD_Valor
    {
        get
        {
            return _PROD_Valor;
        }

        set
        {
            _PROD_Valor = value;
            OnPropertyChanged(nameof(PROD_Valor));
        }
    }

    #endregion
}`

Here is my "select":
public IEnumerable GetProdutos()
{
lock (collisionLock)
{
var query = (from cust in database.Table()
select cust);

            return query;
        }
    }

Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>