lundi 16 novembre 2015

inserting muliple lines to a database table using LINQ query

I'm try to insert all the ith values to table called AB_Product_vs_Field but its only insert last i values only

this is that LINQ query

            for (int i = 0; i < product.ListProductFields.Count; i++)
            {
                insertproductvalue.Product_ID = product.Product_ID;
                insertproductvalue.Field_ID = product.ListProductFields[i].ProductFieldID;
                insertproductvalue.Field_Value_EN = product.ListProductFields[i].Field_Value_EN;

            };

            db.AB_Product_vs_Field.Add(insertproductvalue);
            db.SaveChanges();

How to insert all of those rows one by one

Aucun commentaire:

Enregistrer un commentaire