Deleting row from file table using LINQ in .NET Core 3.1

1

I have an SQL Server with FILESTREAM enabled and a file table populated with a number of rows. I want to be able to delete a selected row from this table using LINQ in .NET Core 3.1.

In my infrastructure layer, I have implemented the following:


public async Task<bool> DeleteReport(Guid streamId)
{
    var query = _dbContext.ReportFileTable
                          .Remove(await _dbContext.ReportFileTable
                                                  .Where(e => e.stream_id.Equals(streamId))
                                                  .FirstOrDefaultAsync());
    var saved = await _dbContext.SaveChangesAsync();
    
    return saved == 1 ? true : false;
}

This approach works just fine for my other regular database tables, but it fails for the FileTable and returns with a timeout when executing _dbContext.SaveChangesAsync(); despite that the query itself shows that the row is marked for deletion.

Microsoft.EntityFrameworkCore.DbUpdateException
---> Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired.

I know that .NET Core support for FileStream is little to none. How do I get around this?

linq
asp.net-core
filestream
filetable
asked on Stack Overflow Feb 11, 2021 by Scopperloit • edited Feb 11, 2021 by Lazar Đorđević

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0