linq2db / linq2db.EntityFrameworkCore

Bring power of Linq To DB to Entity Framework Core projects
MIT License
462 stars 38 forks source link

What is the idiomatic way to truncate a table? #206

Closed nathan-alden-sr closed 2 years ago

nathan-alden-sr commented 2 years ago

I can't figure out what the idiomatic way is to truncate a table. I can see a few TruncateTable method signatures here:

image

but they seem to require objects that I can only find internally when I inspect the library source code. I'm guessing I'm supposed to somehow acquire a PostgreSQLSqlBuilder.

I'd rather not build the raw SQL because I want to get free table name mapping. I'm trying to avoid hardcoding table names.

nathan-alden-sr commented 2 years ago

I figured it out:

await _context.MyTable.ToLinqToDBTable().TruncateAsync();