Reputation: 12862
I have a DbSet<Photo>
that I would like to use as a proxy to actual objects:
public DbSet<Photo> Photos {
get { return (DbSet<Photo>)DbPhotos.Where(s => !s.ToDelete); }
set; // compilation error
}
For some reason, set
is unhappy saying Accessor must declare a body
.
How do I implement the default set
behavior while overriding the get
?
Upvotes: 1
Views: 684
Reputation: 605
You just need the braces.
public DbSet<Photo> Photos {
get { return (DbSet<Photo>)DbPhotos.Where(s => !s.ToDelete); }
set {}
}
As another commenter said, as soon as you give either get
or set
a body, the property is no longer an auto-property. So the syntax won't allow you to treat it as such.
Upvotes: 1