私はリピーターをループし、c#SqlCommandを使用してデータベースに更新クエリを実行しています
後で、新しく更新されたタイプのエンティティタイプが必要なときに使用します
Document d = (from c in db.Documents where c.Id = myID select c).First();
SqlCommandを使用して更新されたフィールドがまだnullであるドキュメントを取得しましたが、dbを確認すると、フィールドの値は正しいです。
SqlCommandコマンドからエンティティタイプを取得する方法、またはLinq-To-Sqlが更新されたデータを取得することを確認する方法はありますか。
これを行う前にdb.savechanges()を実行してみましたが、違いはありません。
編集:
SqlCommand command = getCommand(type, field, item, nDocID, required); // commandText = "UPDATE Documents SET " + field + "=@" + field + " WHERE DocumentID = " + id; "
if (command != null)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connString"].ConnectionString);
command.Connection = conn;
conn.Open();
command.ExecuteNonQuery();
conn.Close();
}