我正在尝试使用模型对象来使我的代码不那么脆弱,但我相信语法有问题。
在美光ORM文档 https://kimtooflex.gitbook.io/workspace/crud/find-search-records 文档中,它显示以下示例:
MicronDbContext micron = new MicronDbContext();
//gets all customers from Nairobi city
var customers = micron.GetRecords<Customer>(
new Customer()
{
City = "Nairobi"
}
);
foreach (var customer in customers)
{
Console.WriteLine(customer.CustomerName);
}
这是我尝试过的,该值一直显示 NULL。这是语法错误吗?
我试图实现的是以下sql命令:
//IEnumerable<Places> places = micron.GetRecords<Places>("SELECT * FROM `places` WHERE `id` = '" + frmPlaceList.chid + "'");
这是不起作用的:
var places = micron.GetRecords<Places>(
new Place()
{
id = frmPlaceList.chid
}
);
我收到的错误是它给了我错误的 ID。如何修复我的代码来解决此问题?
编辑:ORM存在一个错误,它没有输出正确的值。目前正在处理此问题,但尚未修复。
这是我输入的代码:
tabulate1.SubscribeHook("edit", (e) =>
{
new Lib.Popup.transparentBg(this.ParentForm, new Forms.frmFournisseur(Program.db.GetRecord<Fournisseur>(1)));
LoadData();
});
它总是给我第一个录音,我无法访问其他录音。谢谢
试试这个:
IEnumerable<Places> places = micron.GetRecords<Places>($"id='{ frmPlaceList.chid}'");