6

I have this method:

public async Task<int> RemoveClassify(RemoveClassifyVm vm)
{
    return await _db.UserAccesses
        .Where(UserAccess => vm.userAccessIds.Any(userAccessId => userAccessId == UserAccess.Id))
        .ExecuteUpdateAsync(UserAccess => UserAccess
         .SetProperty(UserAccess => UserAccess.ClassId, null)
        );
}

but get error : Error CS0121 The call is ambiguous between the following methods or properties: 'SetPropertyCalls.SetProperty(Func<TSource, TProperty>, Func<TSource, TProperty>)' and 'SetPropertyCalls.SetProperty(Func<TSource, TProperty>, TProperty)'

2 Answers 2

23

we must use : (int?)null

SetProperty(userAccess => userAccess.ClassId, (int?)null)
Sign up to request clarification or add additional context in comments.

Comments

-3

Use this:

SetProperty(UserAccess => UserAccess.ClassId, UserAccess => null)

2 Comments

Please see @m-komaei's answer. Your answer will result in an ambiguous invocation error.
@DaveBagler Not for me. VS understands to call the func prototype here. You can also omit the TSource property: _ => null This comes in handy not having to look up and specify types for multiple columns

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.