eloquera对象的唯一ID映射和断开连接的场景
嗨,请原谅我的英语我是法语人士
我正在开发一个使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论