c# - What data type should an MVC model class use to back/represent a database column of type Image? -
in playing along "programming razor," i've run conundrum. if have table these columns:
id int title nvarchar body ntext photo image
...how should corresponding mvc model class declared? have:
public class blogpost { public long id { get; set; } public string title { get; set; } public string body { get; set; } public byte[] fauxtoe { get; set; } }
...but byte array image (probably jpg or png) guess, @ best.
it may not perfect answer i'm trying help. according programming entity framework dbcontect j.lerman should used store images...
[column(typename = "image")] public byte[] photo { get; set; }
however, it's code first, after db generated type of columns was... varbinary(max).
and here other book programing entity framework: code first, schema created.
the parameter provided column annotation specific database mapping to. want store photo in sql server image field. long it’s possible coerce type used property database data type specify (e.g., coerce byte[] image), can configure data type.
but said, didn't map image type, varbinary(max)
regarding other fields, trying map int long id. make sure table called or use table attribute.
Comments
Post a Comment