我的查询返回一个错误,指出“对象必须实现 IConvertible”。错误发生在 .FirstOrDefault() 行上。我正在尝试从数据库中提取 blob 图像并将其返回给 ajax 调用。我一直在寻找 2 天的答案,但找不到任何东西。
[HttpGet]
//[Authorize]
public ActionResult getChartInfo(string ticker)
{
var db = new MarketSymmetricsSite.msxxdbDB();
System.Linq.IQueryable<string> gQuery = (System.Linq.IQueryable<string>)(from mg in db.Markets where mg.tickerID == ticker select mg.pGraph);
string mGraph = gQuery.FirstOrDefault(); ;
byte[] test = new byte[mGraph.Length];
char[] CharArray = mGraph.ToCharArray();
byte[] ByteArray = new byte[CharArray.Length];
for (int i = 0; i < CharArray.Length; i++)
{
ByteArray[i] = Convert.ToByte(CharArray);
}
return Json(ByteArray, JsonRequestBehavior.AllowGet);
}