Editor.NET UploadMany example error when using 'Where' method

Editor.NET UploadMany example error when using 'Where' method

szxszx Posts: 11Questions: 4Answers: 0
edited August 2018 in Editor

I added 'Where' method to 'UploadManyController.cs, line44' that makes no data filtered.
And 'IndexOutOfRangeException' error occurs when executing debug.

Could you tell me how to fix this.

using (var db = new Database(settings.DbType, settings.DbConnection))
{
    var response = new Editor(db, "users")
        .Model<UploadManyModel>()
        .Field(new Field("users.site")
            .Options(new Options()
                .Table("sites")
                .Value("id")
                .Label("name")
            )
        )
        .LeftJoin("sites", "sites.id", "=", "users.site")
        .Where("users.site", "0")
        .MJoin(new MJoin("files")
            .Link("users.id", "users_files.user_id")
            .Link("files.id", "users_files.file_id")
            .Field(
                new Field("id")
                    .Upload(new Upload(request.PhysicalApplicationPath + @"uploads\__ID____EXTN__")
                        .Db("files", "id", new Dictionary<string, object>
                        {
                            {"web_path", Upload.DbType.WebPath},
                            {"system_path", Upload.DbType.SystemPath},
                            {"filename", Upload.DbType.FileName},
                            {"filesize", Upload.DbType.FileSize}
                        })
                        .Validator(Validation.FileSize(5000000, "Max file size is 5000K."))
                        .Validator(Validation.FileExtensions(new[] { "jpg", "png", "gif" }, "Please upload an image."))
                    )
            )
        )
        .Process(request)
        .Data();

    return Json(response);
}

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin

    Hi,

    Thanks for letting me know about this. I'm travelling at the moment, but I'll check this out when I get back (tomorrow) and let you know what I find.

    Allan

  • szxszx Posts: 11Questions: 4Answers: 0

    Thank you very much, Allan.

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    Answer ✓

    In the Mjoin.cs file you will find a line: if (result.Count() != 0) { in the Data method. That line should actually be:

     if (result.Count() != 0 && response.data.Count() != 0)
    

    That will be in the next release of Editor which won't be too far away.

    Regards,
    Allan

This discussion has been closed.