Tools being used:
- Entity Framework 6.0
- System.Data.Sqlite 1.0.98 Package [Latest Stable Build]
Problem: Suppose the Code block given Below:
using(var dbContext = new DatabaseContext())
{
var hugeDataListObj= dbContext.Table1.Select(x=>x.Field1).ToList();
//Do other Stuff here with hugeDataListObj.
// The Below query will fail for Parser Stack overflow.
var requiredResultObj = dbContext.Table2.Where(x=>hugeDataList.Any(y=> y==x.Field1)).ToList();
//but The code given below works out well.
var requiredResultObj = dbContext.Table2.Where(x=>hugeDataList.Contains(x.Field1)).ToList();
/* Below given is the Detailed Exception.*/
"InnerException": {
"ExceptionType": "SQLiteException",
"ExceptionMessage": "SQL logic error or missing database\r\nparser stack overflow",
"StackTrace": " at System.Data.SQLite.SQLite3.Prepare(SQLiteConnection cnn, String strSql, SQLiteStatement previous, UInt32 timeoutMS, String& strRemain)\r\n at System.Data.SQLite.SQLiteCommand.BuildNextCommand()\r\n at System.Data.SQLite.SQLiteCommand.GetStatement(Int32 index)\r\n at System.Data.SQLite.SQLiteDataReader.NextResult()\r\n at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)\r\n at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)\r\n at System.Data.SQLite.SQLiteCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\r\n at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)\r\n at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)\r\n at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)\r\n at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\r\n at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)",
"Data": {},
"ErrorCode": "-2147467259",
"Source": "System.Data.SQLite",
"HelpLink": null,
"InnerException": null
}
}
I have looked at the Query of Any and Contains. Both have a Huge difference. But then What i am confused about is that is Any() has got a Performance issue ? Or is this is Case Specific?
Aucun commentaire:
Enregistrer un commentaire