views:

31

answers:

1

i can this with ado.net but i want to use it linqtosql

foreach (string ky in ld.Keys)
{
cmd.Parameters.AddWithValue(ky, ld[ky]);
}
public bool AccessProcess(string sp, ListDictionary ld, CommandType cmdType)
{
SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["conn"].ToString());
SqlCommand cmd = new SqlCommand(sp, con);
try
{
con.Open();
cmd.CommandType = cmdType;
foreach (string ky in ld.Keys)
{
cmd.Parameters.AddWithValue(ky, ld[ky]);
}
cmd.ExecuteNonQuery();
}
finally
{
con.Dispose();
cmd.Dispose();
}
return true;
}
}

How can i use addwithValue method in


var engCtx = new DataClasses1DataContext()
{
    entity1 = ld[ky],
    entity2 =ld[ky2],
//    do sometihng. . .. . .
}

i need this:


foreach (string ky in ld.Keys)
{
engCtx.AddWithValue(ky, ld[ky]);
}

A: 

GetCommand?

http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.getcommand.aspx

David B
i don't understand it?
Phsika