//创建LINQ查询语句,判断用户名是否存在
var result = from v in ddc.Users
where v.Name==tbUserName.Text.Trim()
select v;
if(result==null) response.write("not exist");
------最佳解决方案-------------------- 没错,不过没必要
如果你用的ef之类的orm
result.FirstOrDefault() 生成的sql语句是 select top 2 * from...
result.Count() 是 select count(1) from... ------其他解决方案-------------------- var result = from v in ddc.Users
where v.Name==tbUserName.Text.Trim()
select v;
if(result.FirstOrDefault()==null) response.write("not exist");