locked
Azure SQL Data Sync, LINQ optimization bug RRS feed

  • Question

  • How can I report the following Bug ?

    var empty = new Set<int>();

    var query = storage.table.Where(item => empty.Contains(item.id)); // Entity Framework Extended query.DeleteAsync()

    The query is optimized to something like this, because the set is empty, and therefore the result set is always empty:

    SELECT 
     CAST(NULL AS uniqueidentifier) AS [C1], 
     CAST(NULL AS uniqueidentifier) AS [C2], 
     CAST(NULL AS int) AS [C3], 
     CAST(NULL AS int) AS [C4], 
     CAST(NULL AS datetime2) AS [C5], 
     CAST(NULL AS varchar(1)) AS [C6], 
     CAST(NULL AS int) AS [C7]
     FROM  ( SELECT 1 AS X ) AS [SingleRowTable1]
    	WHERE 1 = 0

    Now the problem is that update and delete trigger, introduced by Azure SQL Data Sync, will fail because they require the primary key, which is not part of the optimized query. Meaning that when the set is empty the triggers will fail, but if the set contains an id, the query is not optimized and therefore will succeed.

    (SELECT [i].[PrimaryKeyId] FROM DELETED AS [i])
    Notice, the problem here is not Entity Framework Extended from my perspective, but the Azure SQL Data Sync Triggers! 
    Wednesday, October 15, 2014 12:21 PM

Answers

  • not sure if i understood your post correctly, but the columns available in the logical inserted and deleted tables available in the trigger are the actual columns of the table itself, not the columns in the query that caused the trigger to fire.
    Wednesday, October 15, 2014 1:11 PM

All replies

  • not sure if i understood your post correctly, but the columns available in the logical inserted and deleted tables available in the trigger are the actual columns of the table itself, not the columns in the query that caused the trigger to fire.
    Wednesday, October 15, 2014 1:11 PM
  • Ok ... sorry for wasting your time... it does seem to be a Entity Framework Extended problem, which is not able to cope with the optimized LINQ Query.
    Wednesday, October 15, 2014 4:06 PM