Skip to content

Instantly share code, notes, and snippets.

View DataGridViewMaskedTextColumn.cs
/**********************************
* Title: DataGridViewColumn Hosting MaskedTextBox
* Author: Juergen Thomas, Berlin (Germany)
* Email: post@vs-polis.de
* Environment: WinXP, NET 2.0
* Keywords: DataGridViewColumn,
* DataGridViewMaskedTextColumn,
* DataGridViewMaskedTextCell,
* DataGridViewMaskedTextControl,
* DataGridViewTextBoxColumn,
@jpolvora
jpolvora / AssociationSetNamingConvention.cs
Last active Aug 29, 2015
Contornar o problema com Firebird, que possui limitação de 31 caracteres em nomes de tabelas, constraints, etc.
View AssociationSetNamingConvention.cs
/// <summary>
/// Firebird possui limitação de 31 caracteres em nomes de tabelas, constraints, etc.
/// Esta convenção limita o nome do AssociationSet para 28 caracteres pois o Script SQL gerado para criação utiliza o AssociationSet.Name para
/// formar a constraint de chave estrangeira FK_{0}, associationSet.Name
/// </summary>
public class AssociationSetNamingConvention : IStoreModelConvention<AssociationSet>
{
public void Apply(AssociationSet item, DbModel model)
{
if (item.Name.Length <= 28)
View select-groupy-sum.cs
public class Dto
{
public int Formato1 { get; set; }
public int Formato2 { get; set; }
public Embalagem Embalagem { get; set; }
public string Produto { get; set; }
public decimal QtdeTotal { get; set; }
public static IEnumerable<Dto> Teste(ArmazemCtx context)
{
View IUnitOfWork.cs
using System;
using System.Linq;
namespace Metavision.Infra.Data
{
public interface IUnitOfWork : IDisposable
{
T Find<T>(params object[] keyValues) where T : class , new();
/// <summary>
View IRepositorio.cs
using System;
using System.Collections.Generic;
namespace Metavision.Infra.Data
{
public interface IRepositorio : IDisposable
{
bool HasChanges { get; set; }
IUnitOfWork UnitOfWork { get; }
}
View DataExtensions.cs
using System;
using System.Collections.Generic;
using System.Linq;
using Metavision.Infra.Data;
namespace Metavision.Infra.Extensions
{
public static class DataExtensions
{
#region extensoes para Repositório
View UnitOfWorkBase.cs
using System;
using System.Collections.Generic;
using System.Data;
namespace Metavision.Infra.Data
{
public abstract class UnitOfWorkBase : IDisposable
{
protected readonly Stack<IRepositorio> StackRepositories
= new Stack<IRepositorio>();
View Container.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Metavision.Infra
{
/// <summary>
/// Service Locator simples
/// </summary>
View CodeFirstUnitOfWork.cs
using System;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Objects;
using System.Linq;
namespace Metavision.Infra.Data
{
/// <summary>
View demonstracao.cs
public void DemonstrarEntityFramework()
{
var dbContext = new MyEntities(); //instancia um dbContext
var uow = new CodeFirstUnitOfWork(dbContext); //instancia um unit_of_work para coordenar repositórios
var repositorioPessoas = new Repositorio<Pessoa>(uow); //cria um novo repositório passando o unitOfWork
var repositorioEnderecos = new Repositorio<Endereco>(uow);//cria um novo repositório passando o unitOfWork
var novaPessoa = repositorioPessoas.CreateNew(); //fabrica uma nova entidade
novaPessoa.Nome = "Jone Polvora"; //seta o valor do campo Nome