日期:2014-05-20  浏览次数:20782 次

SQL转LINQ[高手进]
select c.customer_id 客户编号,
c.customer_name 客户名称,
c.customer_value 客户价值等级,
c.customer_type 客户类别,
c.customer_state 客户状态,
(select top 1 connect_time 
from dbo.business b 
where b.connect_time<=getDate()
and b.customer_id=c.customer_id 
order by connect_time DESC) 最近跟进时间,
(select top 1 connect_time 
from dbo.business b 
where b.connect_time>=getDate() 
and b.customer_id=c.customer_id 
order by connect_time asc) 下次跟进时间,
c.remark 备注
from dbo.customer c
where c.user_id=@id;

------解决方案--------------------
vs2008 存在linq to sql功能

你可以将存储过程映射到**.dbml 文件中,无需任何修改...

使用如下
StandardLMSDataContext db = new StandardLMSDataContext(); //实例化映射文件

db.date(userID);//调用存储过程,data为存储过程名称,userid为输入条件