获取登录用户的特定数据

时间:2012-10-25 09:08:43

标签: c# razor webmatrix

我需要列出登录用户的活动潜在客户,并允许分页和可选择的排序,由于布局要求,我无法使用网格。

过去2天我一直在网上搜索,无法找到任何可行的解决方案

非常感谢任何帮助或指示。

var query = db.Query("SELECT a.listingId, a.datetime, c.details, c.buycommercial, c.buyindustrial, c.buyretail, c.buyland, c.tencommercial, c.tenindustrial, c.tenretail, c.tenland, c.investor, c.developer, d.companyname, d.firstname, d.lastname, d.tel, d.cell, d.email FROM dbo.tblactivebroker a JOIN dbo.tblActiveListing b ON a.ListingId = b.ListingId JOIN dbo.tblListings c ON b.ListingId = c.ListingId JOIN dbo.tblContact d ON c.crmid = d.id WHERE b.active = 'True' AND a.ActiveBrokerID = @0",brokerid);

1 个答案:

答案 0 :(得分:0)

如果您正在讨论扩展查询,可以使用string.Format。

示例:

var query = db.Query(string.Format("SELECT a.listingId, a.datetime, c.details, c.buycommercial, c.buyindustrial, c.buyretail, c.buyland, c.tencommercial, c.tenindustrial, c.tenretail, c.tenland, c.investor, c.developer, d.companyname, d.firstname, d.lastname, d.tel, d.cell, d.email FROM dbo.tblactivebroker a JOIN dbo.tblActiveListing b ON a.ListingId = b.ListingId JOIN dbo.tblListings c ON b.ListingId = c.ListingId JOIN dbo.tblContact d ON c.crmid = d.id WHERE b.active = 'True' AND a.ActiveBrokerID = {0} AND a.listingId = {1} ORDER BY a.ActiveBrokerID", brokerId, listingId)) 

但是,它是2012年,更好的方法是使用LINQEntity Framework