Bug #109997 MySql.Data.dll can't add user-defined type object
Submitted: 9 Feb 2023 5:39 Modified: 25 Apr 12:28
Reporter: 超 刘 Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Connectors: Document Store: DevAPI Severity:S3 (Non-critical)
Version:8.0.32 OS:Any
Assigned to: CPU Architecture:Any
Tags: C#, DevAPI

[9 Feb 2023 5:39] 超 刘
Description:
When I use method "public AddStatement Add(params object[] items)" in class "MySqlX.XDevAPI.Collection",to add data,I can only add anonymous type objects,but can't add user-defined type objects.

I guess maybe there is a bug in class "MySqlX.XDevAPI.DbDoc",
method "private Dictionary<string, object> ParseObject(object val)" ,
code "type.GetProperties(BindingFlags.Public)",
it can't get any properties.

How to repeat:
            var mySession = MySQLX.GetSession("server=localhost;port=33060;user=user;password=user;");

            var myDb = mySession.GetSchema("testDocStor");

            var myColl = myDb.CreateCollection("collection1");

            var datas = new List<object>();
            datas.Add(new User { _id = 14, Name = "Lili", Age = 18 });
            datas.Add(new User { _id = 15, Name = "Lala", Age = 19 });
            myColl.Add(datas.ToArray()).Execute();

    /// <summary>
    /// user
    /// </summary>
    public class User
    {
        public int _id { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }
    }
[25 Apr 12:28] MySQL Verification Team
Hello!

Thank you for the bug report. 
Provided details not enough to reproduce the issue.
Please upgrade to latest version and report us back if issue persist even in latest version along with test case. Thank you.

Regards,
Ashwini Patil