Skip to content

Instantly share code, notes, and snippets.

@fabriciosanchez
Created March 14, 2014 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabriciosanchez/9553523 to your computer and use it in GitHub Desktop.
Save fabriciosanchez/9553523 to your computer and use it in GitHub Desktop.
Repository_General
public class Repository_General: IRepositorioGeneral, IDisposable
{
...
public SeuModeloDeDados db = new SeuModeloDeDados();
private bool disposed = false;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
~Repository_General()
{
Dispose(false);
}
protected virtual void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
if (this.db != null)
{
this.db.Dispose();
this.db = null;
}
}
}
}
public List<VideosRetornados> RetornaQuatroVideosMaisRecentes()
{
try
{
var RetornoVideo = (from v in db.SeusVideos
orderby v.IDVideo descending
select new VideosRetornados
{
_Titulo = v.TituloVideo,
_CaminhoImagem = v.CaminhoBreadcrumbVideo,
_LinkExterno = v.LinkExternoParaOVideo
}).Take(4).ToList();
return RetornoVideo;
}
catch (EntitySqlException ex)
{
throw new Exception(ex.Message);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment