I'm running into an issue on a brownfield project that is using LINQ to SQL whereby a call to Table<T>.DeleteOnSubmit results in a SQL query that has a WHERE clause for every column in the table.
Is this the default behavior and how can I change it so that it only matches on the primary key?
Edit
To confirm, the generated class has a primary key:
[Column(Name="id", Storage="_Id", AutoSync=AutoSync.OnInsert,
DbType="BigInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
public long Id
{
...
}
Yes - the Linq-to-SQL data model has a property called UpdateCheck for each of your columns in any table. That property indicates whether or not that column will be used to check that a row hasn't changed before updating it.
That same property also is used to check that a row hasn't changed before deleting it. So if you just set all the column's (except the primary key) to UpdateCheck = Never in your model, then you should get what you're looking for.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With