Reputation: 923
I am working on Linq Query through the ObservableCollection, but I am not able to convert type binary to byte[].
my code is like this.
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 is the Class of ObservableCollection. so the I am getting error like this.
There was an error parsing the query. [ Token line number = 19,Token line offset = 41,Token in error = MAX ]
byteLogo is the type of the byte[].!
System.Data.SqlServerCe.SqlCeException was caught Message=There was an error parsing the query. [ Token line number = 19,Token line offset = 41,Token in error = MAX ] Source=SQL Server Compact ADO.NET Data Provider HResult=-2147217900 NativeError=25501 StackTrace: at System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan() at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options) at System.Data.SqlServerCe.SqlCeCommand.ExecuteDbDataReader(CommandBehavior behavior) at 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) at 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 source) at HMBL.Bank.GetBankSummary(Int32 intuserid, String stracctype) in E:\Working Folder 2011\MoneyCubePlus\Source\HMBL\TransactionManager\Transaction.cs:line 993 InnerException:
Thanks...!!
Upvotes: 0
Views: 521
Reputation: 26634
I believe the problem is that you are using methods that are not supported by linq to sql
I would change this
byteLogo = Convert.FromBase64String(d.VectorLogo.ToString().Replace("\"", "")),
To
vectorLogo= d.VectorLogo
And then once you have the list locally I would convert it to your byte array with linq to objects
Upvotes: 1