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

时间:2011-10-18 19:05:06

标签: c# database eloquera

借口我的英语,我是一名法语发言人 我正在使用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 282574488338433对象uid
按Enter键完成

0 个答案:

没有答案