If you have encounters an SQLCeException error during a LINQ operation for example Union on a very large data set, check the error message. If the error message shows something like “The database file is larger than the configured maximum database size. This setting takes effect on the first concurrent database connection only.“, then congratulation to you, because you just hit the limit.
The Windows Phone team think any application in phone should not use that much memory, but still some of us might hit this limit. For example like me which required to search through 20,000+ data sets with complicated search conditions. The solution to this problem is pretty simple, add a max database size in the connection string to SQL CE. You will need a complete connection string this time instead of just defind the location of your SQL CE database file.
For example, my connection string before this is as follow:
Then after adding the max database size parameter and convert it to a complete connection string, it will become like this:
@"Data Source='isostore:/CardsDatabase.sdf';Max Database Size=64;"
The 64 in the connection string mean I wants to increase the max database size to 64 MB instead of the default value. Hope this little information can help.