Posted
on Nov 4, 2011
(permalink)
Hi there,
Ok, in my all pages I use Load Operation to load the data. I´m not sure if this is the best way, or if exist some other option to load data quickly.
I also have a global variable do type SGADomainContext that is my context, so when the application starts all information of database goes to this variable, but this part I think that is fast, but is the correct?
Then, in my all pages, I need load data from database, so I use this to populate my observable collections:
public void CarregaParticipantesReuniaoQuePodemVotar()
{
try
{
BloquearLeituraEscritaDados = true;
LoadOperation<ParticipantesReuniao> loadOp = AppGlobais.Globais.ContextoSGA.Load(AppGlobais.Globais.ContextoSGA.GetParticipantesReuniaosQuePodemVotarQuery(AppGlobais.Globais.reuniaoGlobal.IdProp), LoadBehavior.RefreshCurrent, CarregaParticipantesReuniaoQuePodemVotar, false);
}
catch (Exception Erro)
{
parametrosJanela.Closed = null;
parametrosJanela.Header = "Erro a carregar intervenientes da reunião";
parametrosJanela.Content = "\n" + Erro.Message;
RadWindow.Alert(parametrosJanela);
}
}
void CarregaParticipantesReuniaoQuePodemVotar(LoadOperation<ParticipantesReuniao> loadOperation)
{
try
{
List<ParticipantesReuniao> listaParticipantesQuePodemVotar;
listaParticipantesQuePodemVotar = (List<ParticipantesReuniao>)loadOperation.Entities.ToList();
OCParticipantesReuniao = new ObservableCollection<ParticipantesReuniao>(listaParticipantesQuePodemVotar);
if (OCParticipantesReuniao.Count > 0)
{
ParticipanteReuniaoSeleccionado = listaParticipantesQuePodemVotar.FirstOrDefault();
}
}
catch (Exception Erro)
{
parametrosJanela.Closed = null;
parametrosJanela.Header = "Erro a carregar intervenientes da reunião";
parametrosJanela.Content = "\n" + Erro.Message;
RadWindow.Alert(parametrosJanela);
}
}
This is correct?
Here is an example of a class of my model:
using System;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Data.Common;
using System.Collections.Generic;
using Telerik.OpenAccess;
using Telerik.OpenAccess.Metadata;
namespace SGA.Web
{
[Table("ANEXOS")]
[KeyGenerator(KeyGenerator.Autoinc)]
public partial class Anexos
{
private long _Id;
[Column("ID", OpenAccessType = OpenAccessType.Decimal, IsBackendCalculated = true, IsPrimaryKey = true, Length = 22, SqlType = "NUMBER")]
[Storage("_Id")]
public virtual long IdProp
{
get
{
return this._Id;
}
set
{
this._Id = value;
}
}
private long _Tipodocumentoid;
[Column("TIPO_DOCUMENTO_ID", OpenAccessType = OpenAccessType.Decimal, Length = 22, SqlType = "NUMBER")]
[Storage("_Tipodocumentoid")]
public virtual long TipoDocumentoIdProp
{
get
{
return this._Tipodocumentoid;
}
set
{
this._Tipodocumentoid = value;
}
}
private string _Designacao;
[Column("DESIGNACAO", OpenAccessType = OpenAccessType.Varchar, IsNullable = true, Length = 200, SqlType = "NVARCHAR2")]
[Storage("_Designacao")]
public virtual string DesignacaoProp
{
get
{
return this._Designacao;
}
set
{
this._Designacao = value;
}
}
private short _Ficheiro;
[Column("FICHEIRO", OpenAccessType = OpenAccessType.Decimal, Length = 1, SqlType = "NUMBER")]
[Storage("_Ficheiro")]
public virtual short FicheiroProp
{
get
{
return this._Ficheiro;
}
set
{
this._Ficheiro = value;
}
}
private int? _Tamanhoficheiro;
[Column("TAMANHO_FICHEIRO", OpenAccessType = OpenAccessType.Decimal, IsNullable = true, Length = 7, SqlType = "NUMBER")]
[Storage("_Tamanhoficheiro")]
public virtual int? TamanhoFicheiroProp
{
get
{
return this._Tamanhoficheiro;
}
set
{
this._Tamanhoficheiro = value;
}
}
private string _Urlficheiro;
[Column("URL_FICHEIRO", OpenAccessType = OpenAccessType.Varchar, IsNullable = true, Length = 1000, SqlType = "NVARCHAR2")]
[Storage("_Urlficheiro")]
public virtual string UrlFicheiroProp
{
get
{
return this._Urlficheiro;
}
set
{
this._Urlficheiro = value;
}
}
private byte[] _Conteudo;
[Column("CONTEUDO", OpenAccessType = OpenAccessType.Blob, IsNullable = true, SqlType = "BLOB")]
[Storage("_Conteudo")]
public virtual byte[] ConteudoProp
{
get
{
return this._Conteudo;
}
set
{
this._Conteudo = value;
}
}
private short _Visivelreuniao;
[Column("VISIVEL_REUNIAO", OpenAccessType = OpenAccessType.Decimal, Length = 1, SqlType = "NUMBER")]
[Storage("_Visivelreuniao")]
public virtual short VisivelReuniaoProp
{
get
{
return this._Visivelreuniao;
}
set
{
this._Visivelreuniao = value;
}
}
private short _Sit;
[Column("SIT", OpenAccessType = OpenAccessType.Decimal, Length = 1, SqlType = "NUMBER")]
[Storage("_Sit")]
public virtual short SitProp
{
get
{
return this._Sit;
}
set
{
this._Sit = value;
}
}
private string _Insuser;
[Column("INS_USER", OpenAccessType = OpenAccessType.Varchar, Length = 40, SqlType = "VARCHAR2")]
[Storage("_Insuser")]
public virtual string InsUserProp
{
get
{
return this._Insuser;
}
set
{
this._Insuser = value;
}
}
private DateTime _Insdata;
[Column("INS_DATA", OpenAccessType = OpenAccessType.Date, SqlType = "DATE")]
[Storage("_Insdata")]
public virtual DateTime InsDataProp
{
get
{
return this._Insdata;
}
set
{
this._Insdata = value;
}
}
private string _Altuser;
[Column("ALT_USER", OpenAccessType = OpenAccessType.Varchar, IsNullable = true, Length = 40, SqlType = "NVARCHAR2")]
[Storage("_Altuser")]
public virtual string AltUserProp
{
get
{
return this._Altuser;
}
set
{
this._Altuser = value;
}
}
private DateTime? _Altdata;
[Column("ALT_DATA", OpenAccessType = OpenAccessType.Date, IsNullable = true, SqlType = "DATE")]
[Storage("_Altdata")]
public virtual DateTime? AltDataProp
{
get
{
return this._Altdata;
}
set
{
this._Altdata = value;
}
}
private short _Versao;
[Column("VERSAO", OpenAccessType = OpenAccessType.Decimal, Length = 3, SqlType = "NUMBER")]
[Storage("_Versao")]
public virtual short VersaoProp
{
get
{
return this._Versao;
}
set
{
this._Versao = value;
}
}
private string _Nomeoriginalficheiro;
[Column("NOME_ORIGINAL_FICHEIRO", OpenAccessType = OpenAccessType.Varchar, IsNullable = true, Length = 100, SqlType = "NVARCHAR2")]
[Storage("_Nomeoriginalficheiro")]
public virtual string NomeOriginalFicheiroProp
{
get
{
return this._Nomeoriginalficheiro;
}
set
{
this._Nomeoriginalficheiro = value;
}
}
private long _Assuntoid;
[Column("ASSUNTO_ID", OpenAccessType = OpenAccessType.Decimal, Length = 22, SqlType = "NUMBER")]
[Storage("_Assuntoid")]
public virtual long AssuntoIdProp
{
get
{
return this._Assuntoid;
}
set
{
this._Assuntoid = value;
}
}
private TiposDocumento _Tiposdocumento;
[ForeignKeyAssociation(ConstraintName = "A_TD_FK", SharedFields = "TipoDocumentoIdProp", TargetFields = "IdProp")]
[Storage("_Tiposdocumento")]
public virtual TiposDocumento TiposdocumentoProp
{
get
{
return this._Tiposdocumento;
}
set
{
this._Tiposdocumento = value;
}
}
private Assuntos _Assuntos;
[ForeignKeyAssociation(ConstraintName = "A_ASS_FK", SharedFields = "AssuntoIdProp", TargetFields = "IdProp")]
[Storage("_Assuntos")]
public virtual Assuntos AssuntosProp
{
get
{
return this._Assuntos;
}
set
{
this._Assuntos = value;
}
}
private IList<AnexosNotificacao> _Anexosnotificacaos = new List<AnexosNotificacao>();
[Collection(InverseProperty = "AnexosProp")]
[Storage("_Anexosnotificacaos")]
public virtual IList<AnexosNotificacao> AnexosNotificacaos
{
get
{
return this._Anexosnotificacaos;
}
}
[Telerik.OpenAccess.Transient()]
private string _icone;
[Telerik.OpenAccess.Transient()]
private bool _seleccionado;
//[FieldAlias("_icone")]
public string Icone
{
get { return _icone; }
set { _icone = value; }
}
//[FieldAlias("_seleccionado")]
public bool Seleccionado
{
get { return _seleccionado; }
set { _seleccionado = value; }
}
}
}