DataEngine for .NET
オブジェクトへのDataEngine の接続
DataEngine の使用 > DataEngine の接続 > オブジェクトへのDataEngine の接続

With the Data Engine library, you can import data from a collection of objects of a specific class type to the DataEngine table.

To connect Data Engine to Objects, you need to follow the steps given below:

  1. Initialize a new workspace folder relative to the project root directory using the Init method of the Workspace class.

    // プロジェクトのルート ディレクトリに相対的な新しいワークスペース フォルダーを作成して初期化します。
    Workspace workspace = new Workspace();
    workspace.Init("workspace");
    
  2. Create a class having a method that returns a collection of the class objects.

    class Employee
    {
        public int EmployeeID { get; set; }
        public string Department { get; set; }
        public double Salary { get; set; }
        public static List<Employee> GetList()
        {
    
            List<Employee> employeeList = new List<Employee>();
            string[] departments = { "Production", "Finance", "HR", "R&D", "Marketing" };
            Random random = new Random();
            for (int i = 0; i < 1000; i++)
            {
                employeeList.Add(new Employee()
                {
                    EmployeeID = i + 1,
                    Department = departments[random.Next(0,5)],
                    Salary = Math.Round(random.NextDouble() * 100000, 2),
                });
            }
            return employeeList;
        }
    }
    
  3. Retrieve the collection of class objects as shown:

    //特定のクラス タイプのオブジェクトのコレクションを取得します。
    List<Employee> employeeList = Employee.GetList();
    
  4. To connect DataEngine to the retrieved collection of custom objects, create an instance of the ObjectConnector class and pass the Workspace object and the custom collection initialized above as parameters to its constructor. Use the GetData method of the ObjectConnector class to create a DataEngine base table containing the imported data.

    //カスタム コレクションから DataEngine テーブルにデータをインポートします。
    ObjectConnector<Employee> connector = new ObjectConnector<Employee>(workspace, employeeList);
    connector.GetData("Employees");
    

    Once the connection is established, the queries can be defined and executed to fetch the desired data. Refer to Transform Data topic for more information.