Reputation: 2006
I am using FluentNHibernate
, I have a method that takes the JSON post makes a deserialize for the class type and saved it, and after is suppose to make a commit but I am getting the errors on save,
using (ITransaction transacao = _session.BeginTransaction(IsolationLevel.ReadCommitted))
{
_session.Save(cameras);
transacao.Commit();
}
the name of my class already equals the name on the bank, this is my mapping builder.
public MapCAMERAS()
{
Id(i => i.C_CAM);
Map(c => c.C_BAL);
Map(c => c.A_CAM);
Map(c => c.D_CAM);
Map(c => c.E_CAM);
Map(c => c.N_CAM);
Map(c => c.P_CAM);
Map(c => c.S1_CAM);
Map(c => c.S2_CAM);
Map(c => c.T_CAM);
Map(c => c.U_CAM);
Map(c => c.DUMANUT);
}
I check the names in table, all names are correct and I just have C_CAM as Id. For use this application is not necessary authentication. I have one Repository and I make my save method there, and service with method calling my Repository, on my post I'm using MVC.
var service = new ServiceCamera(new RepositoryCamera(session));
var result = new RespostaPost();
result = servico.Gravar(cameras);
Error:
My error is when I make the post method. How can I fix this error?
Upvotes: 2
Views: 1365
Reputation: 1574
Very simple. Possibly you mapping not config the increment type.
Try some like this:
Id(i => i.TableId).GeneratedBy.Increment();
Upvotes: 3