0
使用基本DAL 2从具有tabid的表中获取数据。还想通过DNN API获取Tab Url。我可以加入到Tabs表中,但想要使用api。DNN DAL 2水合物和其他
这是我的模型。
[TableName("My_Products")]
[PrimaryKey("ProductId")]
[Cacheable("My_Products_", CacheItemPriority.Normal, 20)]
public class ProductInfo
{
public ProductInfo()
{
Langs = new List<ProductLangInfo>();
}
public int ProductId { get; set; }
[ReadOnlyColumn]
public string ProductImage { get; set; }
public int LineID { get; set; }
[ReadOnlyColumn]
public string Culture { get; set; }
[ReadOnlyColumn]
public string ProductName { get; set; }
[ReadOnlyColumn]
public string ProductShortDesc { get; set; }
[ReadOnlyColumn]
public int TabId { get; set; }
[ReadOnlyColumn]
public string ProductURL { get; set; } //GET THIS FROM API
[ReadOnlyColumn]
public List<ProductLangInfo> Langs { get; set; }
}
这是我的控制器
public IEnumerable<ProductInfo> GetProducts(string language)
{
using (IDataContext ctx = DataContext.Instance())
{
string sqlCmd = ";WITH cte as (SELECT * FROM [ProductsLang] WHERE Culture = @0)" +
" SELECT Products.*,cte.ProductName, cte.ProductShortDesc, cte.TabId" +
" FROM [Products] as Products" +
" INNER JOIN cte ON Products.ProductId = cte.ProductId";
string order = " ORDER BY Products.ProductId DESC";
return ctx.ExecuteQuery<ProductInfo>(CommandType.Text, sqlCmd + order, language);
}
}
我想我的问题是在哪里是在tabid通过从我查询到的最佳方式DNN API?
所以我应该做我的模型和控制器外,并从前端调用这个? 我的模块是一个角度spa模块,所以我会创建一个webapi服务来返回这个? – nextoneup
你可以把它放入属性本身吗?因此,调用“获取”URL,使对象的人口中的API调用?添加了一些信息给答案,这是未经测试,虽然 –
我认为这也可以工作,但它回来为空。 ' public class ProductLangInfo { public int? ProductsId {get;组; } public string ProductName {get;组; } public string ProductShortDesc {get;组; } public int TabId {get;组; } 私人字符串_productUrl; public string ProductURL { get { return DotNetNuke.Common.Globals.NavigateURL(TabId); } } }' – nextoneup