Tag: c#
-
Microsoft C# Graph SDK: How to handle delta query and token for messages
So I spent two days finding out how to handle delta queries for messages in Microsoft Graph with the C# SDK. The handling of the delta token can be confusing and is not that well documented by Microsoft. I have found an example of delta queries for Users, but it assumes that you can save…
-
C# – Linq To Sql – Handle a Transaction Deadlock
When using Linq To SQL, here’s the pattern I use to retry an operation after it failed because a deadlock occurred in a SQL Database:
-
C# – Linq to Sql – Reattach and Update an entity
If you’d listen to Microsoft, you’d believe than in Linq to SQL, you can’t reattach a changed entity to a new DataContext and submit the changed entity to the database. Well this isn’t true. It can be done with a little bit of foresight. The first step is to make sure that the underlying table…
-
C# : How to Wrap Winword COM InterOp Methods
If you have ever used the Microsoft Office COM Interop classes to automate Word (or any other Office Application), you know those methods often take a lot of parameters, which can be tedious. Note: This was written a while ago before .Net 4.0 was available. .Net 4.0 introduces the dynamic keyword which makes COM Interop…
-
C#: Use verbatim strings for SQL queries
Using verbatim strings for SQL queries can make your code much more readable. For example, which one of the following queries is easier to read? This one? or this one? The SQL engine doesn’t care for the whitespace you introduce in queries with verbatim strings. So do your fellow programmers a favor and use them…