ArrayList objValue = new ArrayList();
{
objValue.Add(TITFVM.TinNo);
objValue.Add(TITFVM.CstNo);
objValue.Add(TITFVM.PanNo);
objValue.Add(TITFVM.CinNo);
objValue.Add(TITFVM.ExciseRegNo);
objValue.Add(TITFVM.ServiceTaxNo);
}
List<Guid> LG = new List<Guid>();
LG.Add(new Guid("FD713788-B5AE-49FF-8B2C-F311B9CB0CC4"));
LG.Add(new Guid("64B512E7-46AE-4989-A049-A446118099C4"));
LG.Add(new Guid("376D45C8-659D-4ACE-B249-CFBF4F231915"));
LG.Add(new Guid("59A2449A-C5C6-45B5-AA00-F535D83AD48B"));
LG.Add(new Guid("03ADA903-D09A-4F53-8B67-7347A08EDAB1"));
LG.Add(new Guid("2F405521-06A0-427C-B9A3-56B8931CFC57"));
var taxinfotaxfieldID = Guid.NewGuid();
var listFiled = new List<TaxInfoTaxFiled>();
for (var item = 0; item < objValue.Count; item++)
{
TaxInfoTaxFiled taxInfoObj = new TaxInfoTaxFiled()
{
TaxInfoTaxFieldID = taxinfotaxfieldID,
TaxFieldID = new Guid(LG[item].ToString()),
FieldValue = objValue[item].ToString()
};
listFiled.Add(taxInfoObj);
db.TaxInfoTaxFileds .Add(taxInfoObj);
db.SaveChanges();
}
return View();
}
all are working fine but for second loop i got one error Violation of PRIMARY KEY constraint 'PK_TaxInfoTaxFiled'. Cannot insert duplicate key in object 'dbo.TaxInfoTaxFiled'.
The statement has been terminated.
In TaxInfoTaxFieldID it calculating same id for all iteration so only i got this error i think so . for that what shall I do? please help me to rectify this issue?