请教高手 linq to sql 如何写 select top1 id 的方法
请帮我把以下方法转成linq 的方法 谢谢啊。。asp.net的
public static string ReadIdDate()
{
StringBuilder texts = new StringBuilder();
string sql = "select top 1 id from BusinessWaybill order by id desc";
string source = "Data Source=1.1.1.1;Initial Catalog=testDB;Persist Security Info=True;User ID=sa;Password=***";
using (SqlConnection conn = new SqlConnection(source))
{
SqlCommand com = new SqlCommand(sql, conn);
conn.Open();
SqlDataReader r = com.ExecuteReader();
try
{
while (r.Read())
{
texts.Append(r.GetInt32(0).ToString());
}
}
finally
{
r.Close();
}
}
return texts.ToString();
}
public static string ReadIdDate()
{
StringBuilder texts = new StringBuilder();
string sql = "select top 1 id from BusinessWaybill order by id desc";
string source = "Data Source=1.1.1.1;Initial Catalog=testDB;Persist Security Info=True;User ID=sa;Password=***";
using (SqlConnection conn = new SqlConnection(source))
{
SqlCommand com = new SqlCommand(sql, conn);
conn.Open();
SqlDataReader r = com.ExecuteReader();
try
{
while (r.Read())
{
texts.Append(r.GetInt32(0).ToString());
}
}
finally
{
r.Close();
}
}
return texts.ToString();
}
...全文
相关推荐
LINQ To SQL 语法及实例大全
Linq to sql(或者叫DLINQ)是LINQ(.NET语言集成查询)的一部分,全称基于关系数据的 .NET 语言集成查询,用于以对象形式管理关系数据,并提供了丰富的查询功能,它和Linq to xml、Linq to objects、Linq to dataset、Linq to entities等组成了强大的LINQ。
LINQ_to_SQL语法及实例大全
LINQ_to_SQL语法及实例大全,超级全面的,只要是你需要的,绝对能找到
LINQ_TO_SQL语法与实例大全
本文档主要讲述的是LINQ_TO_SQL技术,包括语法及很多的实例
C#操作LINQ to SQL组件进行数据库建模的基本教程
主要介绍了C#操作LINQ to SQL组件进行数据库建模的基本教程,LINQ to SQL被集成在.NET框架之中,需要的朋友可以参考下
LINQ语法及实例大全
LINQ语法及实例大全,电子版,LINQ最强总结


