LinkQ Exception
- by Ravi
Hi,
I write Linq query for keep on fetching data from database. First loop table don't
have record , so throwing exception. After first loop i have record in the database, my
query is working properly. Below i specified my query give some suggestion first
loop(no records in table) i have to modify query or query have to change.
Ex:
forloop(History history in historyList)
{
History history1 = (from p in context.History
where p.TransferCode == history.TransferCode
select p).First<History>()
as History;
if(history1 == null)
{
SaveToDataBase(history);
}
else
{
UpdateToDataBase(history1);
}
}
Thinks