这款神器就是LinqPad,来看看官网:https://www.linqpad.net/
LinqPad是免费使用的,但部分功能受限,我看了下,要授权的话花费还挺多的,那就继续快乐的使用基本的免费功能吧
官方提供了2个版本,一个支持.net framework(4.6-4.8),一个支持.net core(3.1-6.0),至于选择哪个版本,根据自己实现需要了!
一、使用自带的LinqToSQL
通过左侧Add connection添加一个链接,创建一个查询,如图:
二、使用自带的EF
然后点开SQL查看语句,发现还是FirstOrDefault()的代码最少,更高效。
-- Region Parameters
-- @__p_0='1'
-- EndRegion
SELECT TOP(2) [t].[pt_no]
FROM (
SELECT TOP(@__p_0) [m].[pt_no]
FROM [MES_Product] AS [m]
) AS [t]
GO
SELECT TOP(1) [m].[pt_no]
FROM [MES_Product] AS [m]
GO
这样比vs每修改下代码就要编译一次再看结果,是不是高效了许多呢,同时查看SQL也很方便(以前都是通过SQL SERVER Profile来看)
三、使用自己的组件
如果自己的组件有包含EF上下文(DataContext)的话,也是可以直接引用并使用的
创建一个查询,如下:
点开SQL查看解析的语句
SELECT TOP (2)
[top].[pt_no] AS [pt_no]
FROM ( SELECT TOP (1) [c].[pt_no] AS [pt_no]
FROM (SELECT
[MES_Product].[pt_id] AS [pt_id],
[MES_Product].[pt_no] AS [pt_no],
[MES_Product].[pt_name] AS [pt_name],
[MES_Product].[pt_name_en] AS [pt_name_en],
[MES_Product].[pt_specifications] AS [pt_specifications],
[MES_Product].[pt_unit] AS [pt_unit],
[MES_Product].[pt_type] AS [pt_type],
[MES_Product].[pt_class] AS [pt_class],
[MES_Product].[pt_remark] AS [pt_remark],
[MES_Product].[pt_preweight] AS [pt_preweight],
[MES_Product].[pt_gross_weigth] AS [pt_gross_weigth],
[MES_Product].[pt_photo] AS [pt_photo],
[MES_Product].[wari_code] AS [wari_code],
[MES_Product].[pt_isexempt] AS [pt_isexempt],
[MES_Product].[isenable] AS [isenable],
[MES_Product].[create_time] AS [create_time],
[MES_Product].[creator] AS [creator],
[MES_Product].[edit_time] AS [edit_time],
[MES_Product].[editor] AS [editor],
[MES_Product].[m_client_id] AS [m_client_id],
[MES_Product].[m_org_id] AS [m_org_id],
[MES_Product].[isdelete] AS [isdelete]
FROM [dbo].[MES_Product] AS [MES_Product]) AS [c]
) AS [top]
GO
SELECT TOP (1)
[c].[pt_no] AS [pt_no]
FROM (SELECT
[MES_Product].[pt_id] AS [pt_id],
[MES_Product].[pt_no] AS [pt_no],
[MES_Product].[pt_name] AS [pt_name],
[MES_Product].[pt_name_en] AS [pt_name_en],
[MES_Product].[pt_specifications] AS [pt_specifications],
[MES_Product].[pt_unit] AS [pt_unit],
[MES_Product].[pt_type] AS [pt_type],
[MES_Product].[pt_class] AS [pt_class],
[MES_Product].[pt_remark] AS [pt_remark],
[MES_Product].[pt_preweight] AS [pt_preweight],
[MES_Product].[pt_gross_weigth] AS [pt_gross_weigth],
[MES_Product].[pt_photo] AS [pt_photo],
[MES_Product].[wari_code] AS [wari_code],
[MES_Product].[pt_isexempt] AS [pt_isexempt],
[MES_Product].[isenable] AS [isenable],
[MES_Product].[create_time] AS [create_time],
[MES_Product].[creator] AS [creator],
[MES_Product].[edit_time] AS [edit_time],
[MES_Product].[editor] AS [editor],
[MES_Product].[m_client_id] AS [m_client_id],
[MES_Product].[m_org_id] AS [m_org_id],
[MES_Product].[isdelete] AS [isdelete]
FROM [dbo].[MES_Product] AS [MES_Product]) AS [c]
这个是.net Framework版本的EF,看来确实比.net Core的臃肿了许多啊!!!
这款神器就说到这里了,对于提高工作效率有很大帮助,苦于免费版没有智能提示,但功能基本上也够用了!