Esempio n. 1
0
    /// <summary>
    /// Build custom query to return file attachments with URL from meta values
    /// </summary>
    /// <param name="schema">IWpDbSchema</param>
    /// <param name="fileIds">Attachment IDs</param>
    /// <param name="virtualUploadsUrl">Virtual Uploads URL for building URLs</param>
    internal static Maybe <string> GetQuery(IWpDbSchema schema, IImmutableList <WpPostId> fileIds, string virtualUploadsUrl)
    {
        // Check for empty list
        if (fileIds.Count == 0)
        {
            return(F.None <string, M.NoFileIdsMsg>());
        }

        // Build query
        return
            ("SELECT " +
             $"`p`.`{schema.Posts.Id}` AS '{nameof(PostAttachment.Id)}', " +
             $"`p`.`{schema.Posts.Title}` AS '{nameof(PostAttachment.Title)}', " +
             $"`p`.`{schema.Posts.Excerpt}` AS '{nameof(PostAttachment.Description)}', " +
             $"`p`.`{schema.Posts.Url}` AS '{nameof(PostAttachment.Url)}', " +
             $"`pm`.`{schema.PostsMeta.Value}` AS '{nameof(PostAttachment.UrlPath)}', " +
             $"CONCAT('{virtualUploadsUrl.EndWith('/')}', `pm`.`{schema.PostsMeta.Value}`) AS '{nameof(PostAttachment.Url)}' " +
             $"FROM `{schema.Posts}` AS `p` " +
             $"LEFT JOIN `{schema.PostsMeta}` AS `pm` ON `p`.`{schema.Posts.Id}` = `pm`.`{schema.PostsMeta.PostId}` " +
             $"WHERE `p`.`{schema.Posts.Id}` IN ({string.Join(',', fileIds.Select(x => x.Value))}) " +
             $"AND `pm`.`{schema.PostsMeta.Key}` = '{Constants.Attachment}';"
            );
    }
Esempio n. 2
0
 /// <summary>
 /// Allow Builder to be injected
 /// </summary>
 /// <param name="schema">IWpDbSchema</param>
 /// <param name="builder">IQueryPostsTaxonomyPartsBuilder</param>
 internal PostsTaxonomyOptions(IWpDbSchema schema, IQueryPostsTaxonomyPartsBuilder builder) : base(schema, builder)
 {
 }
Esempio n. 3
0
 /// <summary>
 /// Internal creation only
 /// </summary>
 /// <param name="schema">IWpDbSchema</param>
 internal PostsTaxonomyOptions(IWpDbSchema schema) : base(schema, new PostsTaxonomyPartsBuilder(schema))
 {
 }
Esempio n. 4
0
 public TestPartsBuilder(IExtract extract, IDbClient client, IWpDbSchema schema) : base(extract, client, schema)
 {
     Table    = Substitute.For <ITable>();
     IdColumn = Substitute.For <IColumn>();
 }
Esempio n. 5
0
 /// <summary>
 /// Internal creation only
 /// </summary>
 /// <param name="extract">IExtract</param>
 /// <param name="schema">IWpDbSchema</param>
 internal PostsMetaPartsBuilder(IExtract extract, IWpDbSchema schema) : base(extract, schema)
 {
 }
Esempio n. 6
0
 /// <summary>
 /// Internal creation only
 /// </summary>
 /// <param name="schema">IWpDbSchema</param>
 internal PostsMetaPartsBuilder(IWpDbSchema schema) : base(schema)
 {
 }
Esempio n. 7
0
 /// <summary>
 /// Internal creation only
 /// </summary>
 /// <param name="schema">IWpDbSchema</param>
 internal PostsOptions(IWpDbSchema schema) : base(schema, new PostsPartsBuilder(schema))
 {
 }
Esempio n. 8
0
 /// <summary>
 /// Internal creation only
 /// </summary>
 /// <param name="extract">IExtract</param>
 /// <param name="schema">IWpDbSchema</param>
 internal TermsPartsBuilder(IExtract extract, IWpDbSchema schema) : base(extract, schema)
 {
 }
Esempio n. 9
0
 /// <summary>
 /// Internal creation only
 /// </summary>
 /// <param name="schema">IWpDbSchema</param>
 internal TermsPartsBuilder(IWpDbSchema schema) : base(schema)
 {
 }
Esempio n. 10
0
 /// <summary>
 /// Internal creation only
 /// </summary>
 /// <param name="schema">IWpDbSchema</param>
 internal TermsOptions(IWpDbSchema schema) : base(schema, new TermsPartsBuilder(schema))
 {
 }
Esempio n. 11
0
 /// <summary>
 /// Allow Builder to be injected
 /// </summary>
 /// <param name="schema">IWpDbSchema</param>
 /// <param name="builder">IQueryTermsPartsBuilder</param>
 internal TermsOptions(IWpDbSchema schema, IQueryTermsPartsBuilder builder) : base(schema, builder)
 {
 }
Esempio n. 12
0
 /// <summary>
 /// Internal creation only
 /// </summary>
 /// <param name="extract">IExtract</param>
 /// <param name="schema">IWpDbSchema</param>
 internal PostsTaxonomyPartsBuilder(IExtract extract, IWpDbSchema schema) : base(extract, schema)
 {
 }
Esempio n. 13
0
 /// <summary>
 /// Internal creation only
 /// </summary>
 /// <param name="schema">IWpDbSchema</param>
 internal PostsTaxonomyPartsBuilder(IWpDbSchema schema) : base(schema)
 {
 }
Esempio n. 14
0
 public TestOptions(IWpDbSchema schema, IQueryPartsBuilder <TestId> builder) : base(schema, builder)
 {
 }
Esempio n. 15
0
 /// <summary>
 /// Allow Builder to be injected
 /// </summary>
 /// <param name="schema">IWpDbSchema</param>
 /// <param name="builder">IQueryPostsMetaPartsBuilder</param>
 internal PostsMetaOptions(IWpDbSchema schema, IQueryPostsMetaPartsBuilder builder) : base(schema, builder) =>
Esempio n. 16
0
 /// <summary>
 /// Internal creation only
 /// </summary>
 /// <param name="schema">IWpDbSchema</param>
 internal PostsMetaOptions(IWpDbSchema schema) : this(schema, new PostsMetaPartsBuilder(schema))
 {
 }