简体   繁体   English

如何在Unity3D中使用LINQ to MySQL?

[英]How can I use LINQ to MySQL in Unity3D?

I am making project in Unity3D using MySQL server. 我正在使用MySQL服务器在Unity3D中制作项目。 How can I make SQL-queries using LINQ? 如何使用LINQ进行SQL查询? Because Unity3D working with .net 2.0 there is no way to use EntityFramework or smth like that, so I am have to type SQL-query by myself like that: 由于Unity3D与.net 2.0一起使用,因此无法使用EntityFramework或smth这样的方法,因此我必须自己输入SQL查询,如下所示:

    var command =
        "INSERT INTO `person` (`surname`, `name`, `patronymic`, `login`, `password`, `category`, `organization`, `city`) VALUES ('" +
        surname +
        "','" + name + "','" + patronymic + "','" + login + "', '" + encrpass + "','" + category + "','" +
        organization + "','" + city + "');";

    try
    {
        var cmd = new MySqlCommand(command, Connection);
        cmd.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
        Debug.Log(ex.ToString());
    }

Whether there is a more simple way to use MySQL from Unity? 是否有更简单的方法从Unity使用MySQL? Thanks. 谢谢。

Have a look at LinqToDb . 看看LinqToDb It also has a version for Mono and it should work with Unity3D. 它还具有用于Mono的版本,并且可以与Unity3D一起使用。

Good luck. 祝好运。

For using LINQ in Unity you can check this thread and see if it helps you. 为了在Unity中使用LINQ,您可以检查该线程 ,看看是否有帮助。

Cheers. 干杯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM