Hi, I'm writing a piece of code that takes the records from a sql ce 3.5 database, creates images based on the url provided and then fill the observablecollection with those Images. It looks like this:
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
Entities db = new Entities();
ObservableCollection<Image> _imageCollection =
new ObservableCollection<Image>();
IEnumerable<library> libraryQuery =
from c in db.ElectricalLibraries
select c;
foreach (ElectricalLibrary c in libraryQuery)
{
Image finalImage = new Image();
finalImage.Width = 80;
BitmapImage logo = new BitmapImage();
logo.BeginInit();
logo.UriSource = new Uri(c.url);
logo.EndInit();
finalImage.Source = logo;
_imageCollection.Add(finalImage);
}
}
I'm getting two errors, when I try to change anything: 1) Cannot convert from IQueryable to IEnumerable 2) The connection string is not valid, not correct for the provider or cannot be found. The DataAccessLayer with the EF model and app.config and this code are placed in two separate projects.
Any suggestions how to write it properly?