我有一个SQL数据源设置,以获得从标准DNN“文件”表中的某个扩展的所有文件,但我想在哪个类别的文件中添加指定额外级别的显示,但不知道如何最好地去做。见我当前的SQL数据源代码如下:2sxc | SQL数据源 - LINQ过滤查询
@using ToSic.Eav.DataSources
@functions
{
// Default data initialization - should be the place to write data-retrieval code
// In the future when routing & pipelines are fully implemented, this will usually be an external configuration-only system
// For now, it's done in a normal event, which is automatically called by the razor host in 2SexyContent
public override void CustomizeData()
{
var source = CreateSource<SqlDataSource>();
// source.TitleField = "EntityTitle"; // not necessary, default
// source.EntityIdField = "EntityId"; // not necessary, default
// source.ConnectionString = "..."; // not necessary, we're using the ConnectionStringName on the next line
source.ConnectionStringName = Content.ConnectionName;
// Special note: I'm not selecting * from the DB, because I'm activating JSON and want to be sure that no secret data goes out
source.SelectCommand = "Select Top 10 FileId as EntityId, FileName as EntityTitle, PublishedVersion, UniqueId, FileName, Size as Size, Extension as Extension, CreatedOnDate as Date, Folder as Folder FROM Files WHERE PortalId = @PortalId AND Extension = 'docx' OR Extension = 'xlsx' OR Extension = 'pdf'";
source.Configuration.Add("@PortalId", Dnn.Portal.PortalId.ToString());
Data.In.Add("FileList", source.Out["Default"]);
// enable publishing
Data.Publish.Enabled = true;
Data.Publish.Streams = "Default,FileList";
}
}
我要同步与DNN的标签/页分类标签的2sxc分类实体/类别,以便允许用户选择在页面设置一个DNN标签,它(如果同步与2sxc分类实体)将允许我分配一个特定DOC/EXCEL/PDF文件(通过2sxc ICACHE已经连接到2sxc类别),以在此基础上通过与内容项目表中加入taxonomy_terms表连接的SQL数据源的应用并依次与连接到DNN选项卡表的内容项目标签表相关联。
我怎样才能更正我下面的LINQ /剃刀代码到我的类别过滤器与分配给他们确切的“服务”类别只显示文件。我将使用此过滤器与分类标签“服务”(精确匹配),我想链接到2sxc类别(已上传的亚当文件已经通过2sxc ICACHE连接)与DNN分类术语“服务”同步?
@foreach (var file in AsDynamic(Data.In["FileList"]).Where(i =>
(i.Category as List<dynamic>).Any(c => c.EntityId == FileList.EntityId)))
{
<li>@file.FileName</li>
}
我已经看过了详细的关于https://github.com/2sic/2sxc/wiki/DotNet-Query-Linq维基笔记,我被困在得到该类别过滤器正确的语法使用与SQL数据源模板的foreach。
干杯......
我会深入了解一下DnnSqlDataSource,THX! – denisjoconnor