cjrancur

Can someone assist in rewriting this C# LINQ code into vb.net?

Discussion created by cjrancur on Dec 11, 2009
Latest reply on Jan 1, 2010 by cescamilla

I found some C# code for using LINQ with repeatable read isolation level to interact with a SQL server.  Can someone help me to build an equivalent version in vb.net?  Or is there a way to just use the C# code within a program that is otherwise vb.net using Visual Studio 2008?

 

http://www.hanselman.com/blog/GettingLINQToSQLAndLINQToEntitiesToUseNOLOCK.aspx

 

I tried other methods of using vb.net transactions to set a repeatable read SQL isolation level.  There were two problems with that.  First, I had date formatting difficulty with inputs to SQL 2000 using coded transactions.  Second, I found that Microsoft does not recommend coding with the "connection.begintransaction" method, because it will become obsolete in future versions of SQL. 

 

The below Microsoft link for the begintransaction method says, "This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. "

 

 http://msdn.microsoft.com/en-us/library/ms140567.aspx

 

I haven't found any suggestions from Microsoft about what should be used to replace the ".begintransaction" method.  That's why I thought I would try to find out if I could use LINQ instead.  I was pleased to find that my date format issues went away when I started using LINQ.  By comparison, when I tested parameterized transactions, I had trouble getting dates to show up as anything but 1/1/1900 on the SQL server.

 

I'd like to figure out how to set the isolation level for SQL using LINQ and vb.net, because I have already found that writing data to the SQL server works well with LINQ in vb.net.

Attachments

Outcomes