我正在通过ObservableCollection处理Linq Query,但我无法将二进制类型转换为byte []。
我的代码是这样的。
q1 = (from a in Helper.db.AccountStatement
join b in Helper.db.BankAccount on a.BankAccId equals b.BankAccId
join c in Helper.db.BankBranch on b.BankBranchId equals c.BankBranchId
join d in Helper.db.Bank on c.BankId equals d.BankId
where b.AccType == stracctype && b.UserId == intuserid && a.ActiveStatement == true && b.ActiveAccount == true
group new { b, d, a } by new { b.BankAccId, d.Name, b.AccNumber } into h
select new BankSummaryDataGrid
{
BankAccId = h.Key.BankAccId,
byteLogo = Convert.FromBase64String(d.VectorLogo.ToString().Replace("\"", "")),
BankName = h.Key.Name,
AccountNumber = h.Key.AccNumber,
ClosingBalance = ((h.Where(p => p.a.TxtType == HMBL.WealthManager.WMCoAEntities.clsTransactionType.strDr).Sum(p => p.a.TxnAmt) == null ? 0.0 : h.Where(p => p.a.TxtType == HMBL.WealthManager.WMCoAEntities.clsTransactionType.strDr).Sum(p => p.a.TxnAmt)) - (h.Where(p => p.a.TxtType == HMBL.WealthManager.WMCoAEntities.clsTransactionType.strCr).Sum(p => p.a.TxnAmt) == null ? 0.0 : h.Where(p => p.a.TxtType == HMBL.WealthManager.WMCoAEntities.clsTransactionType.strCr).Sum(p => p.a.TxnAmt)))
}).ToList();
BankSummaryDataGrid是ObservableCollection的类。所以我得到这样的错误。
解析查询时出错。 [令牌行号= 19,令牌行偏移= 41,令牌错误= MAX]
byteLogo是byte []的类型。!
捕获了System.Data.SqlServerCe.SqlCeException Message =解析查询时出错。 [令牌行号= 19,令牌行偏移= 41,令牌错误= MAX] Source = SQL Server Compact ADO.NET数据提供程序 的HResult = -2147217900 NativeError = 25501 堆栈跟踪: 在System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan() 在System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior,String method,ResultSetOptions options) 在System.Data.SqlServerCe.SqlCeCommand.ExecuteDbDataReader(CommandBehavior行为) 在System.Data.Common.DbCommand.ExecuteReader() at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query,QueryInfo queryInfo,IObjectReaderFactory factory,Object [] parentArgs,Object [] userArgs,ICompiledSubQuery [] subQueries,Object lastResult) at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query,QueryInfo [] queryInfos,IObjectReaderFactory factory,Object [] userArguments,ICompiledSubQuery [] subQueries) at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) 在System.Data.Linq.DataQuery
1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() at System.Collections.Generic.List
1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable
1来源) 在E:\ Working Folder 2011 \ MoneyCubePlus \ Source \ HMBL \ TransactionManager \ Transaction.cs中的HMBL.Bank.GetBankSummary(Int32 intuserid,String stracctype):第993行 InnerException:
...谢谢!
答案 0 :(得分:1)
我认为问题在于您使用的是linq对sql
不支持的方法我会改变这个
byteLogo = Convert.FromBase64String(d.VectorLogo.ToString().Replace("\"", "")),
要
vectorLogo= d.VectorLogo
然后,一旦你在本地列表,我会将它转换为你的字节数组与linq到对象