将sql语句转换为Linq表达式 [英] Translate sql statement to Linq expression

查看:79
本文介绍了将sql语句转换为Linq表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我对Linq和lambda不太熟悉.
我有此SQL语句,我想将其转换为Linq或Lamda表达式.

Hello!

I''m not that familiar with Linq and lambda.
I have this SQL statement that i want to translate into a Linq or Lamda expression.

Select A, C, D, Count(D) AS ‘E’ FROM TABLE
WHERE C = 2 AND D = 4 
GROUP BY A, C, D



有人可以帮我将其翻译成Linq或Lambda吗?

谢谢!



Can someone help me translate this into Linq or Lambda?

Thanks!

推荐答案

这只是一个示例,不知道运行时结果::

This is just an example don''t know the run time results::

var z = from x in Table
where x.c = 2 and d = 4
select  A = x.a, B = x.b ,D =x.d , E = x.D.Count()



但是你可以从中得到想法

您也可以从此链接获得帮助

如何:LINQ到SQL转换-第II部分 [



But you can get idea from this

You also can take help from this link

How To: LINQ To SQL Transformations - Part II[^]


尝试
将SQL转换为LINQ,第1部分:基础知识(Bill Horst) [
Try
Converting SQL to LINQ, Part 1: The Basics (Bill Horst)[^]


here i am posting some thing about Linq basic operation select, insert, delete, update.




http://suhasharidas.blogspot.in/2012/08/create- linq-to-sql-connection-with.html [ ^ ]




http://suhasharidas.blogspot.in/2012/08/create-linq-to-sql-connection-with.html[^]


这篇关于将sql语句转换为Linq表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆