Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Delete function returning an error #4288


User avatar
0
Garysund created

Hi There

I am trying to delete all records that are linked to a particular UserId. I have added a foreign key to the user table.

I am using the following Function

await _userCategoryRepository.DeleteAsync(p => p.UserId == AbpSession.UserId.GetValueOrDefault());

Could it have something to do with Cascade delete.

I dont want to lookup all the items then delete them as it will add processing time.

Thanks


6 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    What's the error?

  • User Avatar
    0
    Garysund created

    Was testing it from Swagger as its going to be called from a mobile app.

    An internal error occurred during your request!

    I will put a try catch and see what the error is.

  • User Avatar
    0
    aaron created
    Support Team

    You can check Logs.txt for full stack trace.

  • User Avatar
    0
    Garysund created

    This is the error in the log file

    System.NotSupportedException: LINQ to Entities does not recognize the method 'Int64 GetValueOrDefault()' method, and this method cannot be translated into a store expression.

  • User Avatar
    0
    aaron created
    Support Team

    Change to AbpSession.UserId.Value

  • User Avatar
    0
    Garysund created

    Awesom working now thanks