eloquera对象的唯一ID映射和断开连接的场景

发布于 2024-12-10 18:26:58 字数 1313 浏览 4 评论 0原文

嗨,请原谅我的英语我是法语人士
我正在开发一个使用 eloquera 作为数据库的 asp.net mvc 项目。
我遇到了对象 uid 自动映射问题。
数据库生成的uid没有映射到对应的对象字段。
请有人告诉我我的代码

类程序 有什么问题 {

    static void Main(string[] args)
    {
        var dbname = "testElo";
        DB db = new DB("server=localhost;password=pwd;options=none;");
        db.DeleteDatabase(dbname, true);
        db.CreateDatabase(dbname);
        db.OpenDatabase(dbname);
        var p = new Person()
                    {
                        Nom = "giscard"
                    };
        var uid = db.Store(p);
        db.Close();
        db.OpenDatabase(dbname);
        db.RefreshMode = ObjectRefreshMode.AlwaysReturnUpdatedValues;
        var tmp = (from Person per in db select per).ToList().SingleOrDefault();
        Console.WriteLine("expected uid {0}", uid);
        Console.WriteLine("object uid using PersonId field {0}", tmp.PersonId);
        Console.WriteLine("object uid using db.GetUid {0}", db.GetUid(tmp));

        Console.WriteLine("press enter to finish");
        Console.ReadLine();
    }

    class Person
    {
        [ID]
        public int PersonId;
        public string Nom;
    }

这是预期的输出

uid 282574488338433
使用 PersonId 字段 0 的对象 uid
使用 db.GetUid 的对象 uid 282574488338433
按 Enter 完成

hi excuse for my english iam a french speaker
I am working on a asp.net mvc project using eloquera as the database.
I have encounter problem with the object uid auto mapping.
the uid generated by the database is not mapped to the corresponding object field.
please can someone tell me what is wrong with my code

class Program
{

    static void Main(string[] args)
    {
        var dbname = "testElo";
        DB db = new DB("server=localhost;password=pwd;options=none;");
        db.DeleteDatabase(dbname, true);
        db.CreateDatabase(dbname);
        db.OpenDatabase(dbname);
        var p = new Person()
                    {
                        Nom = "giscard"
                    };
        var uid = db.Store(p);
        db.Close();
        db.OpenDatabase(dbname);
        db.RefreshMode = ObjectRefreshMode.AlwaysReturnUpdatedValues;
        var tmp = (from Person per in db select per).ToList().SingleOrDefault();
        Console.WriteLine("expected uid {0}", uid);
        Console.WriteLine("object uid using PersonId field {0}", tmp.PersonId);
        Console.WriteLine("object uid using db.GetUid {0}", db.GetUid(tmp));

        Console.WriteLine("press enter to finish");
        Console.ReadLine();
    }

    class Person
    {
        [ID]
        public int PersonId;
        public string Nom;
    }

here is the ouput

expected uid 282574488338433

object uid using PersonId field 0

object uid using db.GetUid 282574488338433

press enter to finish

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文