Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table<T>.DeleteOnSubmit generated SQL matching all columns

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
{
    ...
}
like image 617
Richard Szalay Avatar asked Dec 11 '25 09:12

Richard Szalay


1 Answers

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.

enter image description here

like image 109
marc_s Avatar answered Dec 14 '25 02:12

marc_s