miche...@gmail.com
unread,Jul 6, 2015, 10:43:55 AM7/6/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to aut...@googlegroups.com
Hi All!
i'm trying to use autofac in winform application, i can read records but i can't add or update record. no error is generated but add and update doesn't work.
in the program.cs i put :
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var builder = new ContainerBuilder();
builder.RegisterType<SisalWorkFlow.Infrastructure.DatabaseFactory>().AsImplementedInterfaces().InstancePerDependency();
builder.RegisterType<SisalWorkFlow.Infrastructure.UnitOfWork>().AsImplementedInterfaces().InstancePerDependency();
builder.RegisterType<SisalWorkFlow.Data.ReadOnly.Repository.SisalMasterRepository>().As<SisalWorkFlow.Data.ReadOnly.Repository.ISisalMasterRepository>();
builder.RegisterType<SisalWorkFlow.Service.Services4Read.SisalMasterService>().As<SisalWorkFlow.Service.Services4Read.ISisalMasterService>();
builder.RegisterType<SisalWorkFlow.Data.Repository.SisalMasterRepository>().As<SisalWorkFlow.Data.Repository.ISisalMasterRepository>();
builder.RegisterType<SisalWorkFlow.Service.SisalMasterService>().As<SisalWorkFlow.Service.ISisalMasterService>();
builder.Register(f => new MDIParent1(f.Resolve<SisalWorkFlow.Service.Services4Read.ISisalMasterService>()
, f.Resolve<SisalWorkFlow.Service.ISisalMasterService>())).As<MDIParent1>();
using (var container = builder.Build())
{
Application.Run(container.Resolve<MDIParent1>());
}
}
into the MDIParent1.cs i put
public partial class MDIParent1 : Form
{
private int childFormNumber = 0;
Service.Services4Read.ISisalMasterService _sisalMasterReadOnlyService;
Service.ISisalMasterService _sisalMasterService;
public MDIParent1(Service.Services4Read.ISisalMasterService sisalMasterReadOnlyService, Service.ISisalMasterService sisalMasterService)
//public MDIParent1()
{
InitializeComponent();
_sisalMasterReadOnlyService = sisalMasterReadOnlyService;
_sisalMasterService = sisalMasterService;
}
private void elencoToolStripMenuItem_Click(object sender, EventArgs e)
{
Lavorazioni _lavorazioni = new Lavorazioni(_sisalMasterReadOnlyService);
// Set the Parent Form of the Child window.
_lavorazioni.MdiParent = this;
// Display the new form.
_lavorazioni.Show();
}
private void creaToolStripMenuItem_Click(object sender, EventArgs e)
{
CreaLavorazione _creaLavorazione = new CreaLavorazione(_sisalMasterService);
// Set the Parent Form of the Child window.
_creaLavorazione.MdiParent = this;
// Display the new form.
_creaLavorazione.Show();
}
into the form that add record:
public partial class CreaLavorazione : Form
{
Service.ISisalMasterService _sisalMasterService;
public CreaLavorazione(Service.ISisalMasterService sisalMasterService)
{
InitializeComponent();
_sisalMasterService = sisalMasterService;
}
private void button1_Click(object sender, EventArgs e)
{
var _dm = new SisalMaster()
{
DataInserimento = DateTime.Now,
ID = 0,
Nota = txtNota.Text
};
_sisalMasterService.AddSisalMaster(_dm);
}
}
thanks in advance
Michele