は、私は次のインタフェースを持っている:byte []値をSQL型Imageにマップするにはどうすればよいですか?
IEnumerator<SqlDataRecord> IEnumerable<SqlDataRecord>.GetEnumerator()
{
var SQLRow = new SqlDataRecord(
new SqlMetaData("id", SqlDbType.BigInt),
new SqlMetaData("image", SqlDbType.Image));
foreach (ImageModel item in this)
{
SQLRow.SetSqlInt64(0, item.Id);
// here is the problem (this is a byte[] variable)
SQLRow.SetSqlByte(1, item.Image);
yield return SQLRow;
}
}
は、どのように私はImage
にbyte[]
をマッピングすることができますか?または、私は別の方法で画像を保存することができますか?
ありがとうございます。
OK。パフォーマンスの問題はどうですか?私が 'NVARCHAR(MAX)'と 'Image'の違いとして保存すると、何が欠点ですか? –
byte []を使用すると、nvarchar(max)よりもパフォーマンスが向上します。nvarcharは、さまざまなエンコーディングをサポートする文字列を意味します。ケースについては、http://stackoverflow.com/questions/25400555/save- and-retrieve-image-binary-from-sql-server-using-entity-framework-6 – Naganathan