private Table<Gallery> galleryTable;
public GalleryRepository ( string connectionString ) {
dc = new DataContext(connectionString);
galleryTable = dc.GetTable<Gallery>();
}
public void SaveGallery(Gallery gallery) {
if (gallery.GalleryId == 0)
galleryTable.InsertOnSubmit(gallery);
else if (galleryTable.GetOriginalEntityState(gallery) == null) {
galleryTable.Attach(gallery);
galleryTable.Context.Refresh(RefreshMode.KeepCurrentValues, gallery);
}
galleryTable.Context.SubmitChanges();
}
When inserting a new gallery into the table, the method throws a Object reference not set to an instance of an object error. The gallery is not null and neither is the galleryTable Thanks in advance
So the problem was with my Gallery entity I had
and it was throwing a null reference at
this._Tags.Assign(value);
So i assigned a blank EntitySet to the _Tags variable and problem solved