Closed Amplificator closed 2 years ago
I'm trying o get familiar with Iridium and so far I'm liking it.
I'm trying to do basic CRUD but my update statement doesn't seem to work.
using (var db = new DbContext()) { var template = db.Templates.FirstOrDefault(x => x.Title == item); template.Title = txtTitle.Text; template.Text = txtPredefinedMessage.Text; db.Templates.Update(template); }
Debugging shows that it gets the template just fine and fields update but the issue is committing the update to the database. I've also tried with just db.Update(template) and .Save as well - what am I missing?
Does the Templates table have a primary key? Update() or Save() requires a primary key
It does. The SQL code is this: https://paste.mozilla.org/5TarCTNp
That should work the way you wrote it. Can you share the declaration of the Template
class?
I have this:
public IDataSet<Templates> Templates { get; set; }
namespace hoejdata_cpsms
{
public class Templates
{
public int Id { get; set; }
public string Title { get; set; }
public string Text { get; set; }
}
}
That is the entire class.
Although this should work in theory, can you try adding the [Column.PrimaryKey]
attribute to the Id
field?
That worked, thank you! :)
Thanks. I'll make a note of that. It may be an issue with the MySql driver
I'm trying o get familiar with Iridium and so far I'm liking it.
I'm trying to do basic CRUD but my update statement doesn't seem to work.
Debugging shows that it gets the template just fine and fields update but the issue is committing the update to the database. I've also tried with just db.Update(template) and .Save as well - what am I missing?