SQL To LinQ 你知道嗎?,sqllinq

來源:互聯網
上載者:User

SQL To LinQ 你知道嗎?,sqllinq

    學習linQ的時候,你應該用到過LinQ to SQL 的工具---LinQPad,剛開始用,不太熟悉,尤其是涉及到多表查詢,不會寫LinQ語句怎麼辦?

   這不是問題,下面先來介紹另一個工具 SQL to LinQ,SQL已經學了很長時間了,做系統的時候經常用到,對於SQL語句應該不陌生吧。

   開啟SQL Server 2008 ,建立查詢,我想把三張表中的資訊一一對應起來,並且只要我想要的欄位的資訊,SQL語句: 

SELECT [t2].[VirtualExamRoomId], [t2].[VirtualExamRoomName], [t0].[ExamId], [t0].[ExamName], [t1].[ExamineeExamId], [t1].[ExamineeName]FROM [ExamExamEntity] AS [t0], [ExamExamineeExamEntity] AS [t1], [ExamExamRoomPlanEntity] AS [t2]WHERE ([t0].[ExamId] = [t1].[ExamExamEntityExamId]) AND ([t1].[ExamExamRoomPlanEntityVirtualExamRoomId] = [t2].[VirtualExamRoomId])
   

  執行,顯示我想要的三張表中相關的欄位資訊:

  

   

  然後,開啟SQL to LinQ,Tools--Linqer Connections,建立串連:

  

  

  選擇Add:



設定要串連的資料庫,


選擇LinQ to Entities:

建立要相關檔案,放在某一個檔案夾下:


 確認,將SQL語句複製到左邊的SQL框中,在上邊的Connection中選擇你剛建立的串連,執行,然後右邊就會把相應的LinQ語句顯示出來:


  把LinQ語句,複製到LinqPad中,運行:



 Perfect!!!,善用工具,提高開發效率!

   

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.