I am Getting below error in Framework 4.5 WCF application.
Is there any missing file or else. I don't getting exactly here.
I am Getting below error in Framework 4.5 WCF application.
Is there any missing file or else. I don't getting exactly here.
Depends how your class does look like. Based on your screenshot you should change it to this
public void Update<T>(T obj, params Expression<Func<T, object>>[] propertiesToUpdate)
{
}
Your version is only working, if the class would look like
public class YourClass<T>
{
public void Update(T obj, ...
{
}
}
And here are the basics.
Edit
Either you forgot to post it or you're doing it wrong.
If you're looking at the doc of DbContext.Set<T>()
, then you'll see, that there is a constrain saying where T : class
. (That's what I already mentioned in a comment.) That means, that your generic type has to meet the same requirement. Therefore you need to change your method to the following, since it need to be at least as specific as DbContext.Set<T>()
.
public void Update<T>(T obj, params Expression<Func<T, object>>[] propertiesToUpdate) where T : class
{
}
Last but not least, an advice. Deal with the basic of generics. It's pretty important. Once you have understood the whole thing, it can be very powerful in certain scenarios.
You need to do like this:
public void Update<T>(Task obj, params Expression<Func<T, object>>[] propertiesToUpdate)