asp.net mvc - How can I create multiple new instances of a model and save them to the database? -
i'm using following code attempt import csv file. saving last object of fact rather saving each of objects built.
do while not sr.endofstream dim afact fact dim marray = sr.readline().split(",") afact.name = marray(0) afact.value = marray(1) db.facts.add(afact) end db.savechanges()
just use list save object
dim factlist new list(of fact) ' add list while not sr.endofstream dim afact fact dim marray = sr.readline().split(",") afact.name = marray(0) afact.value = marray(1) factlist.add(afact) ' put fact object in list end
Comments
Post a Comment