Sto compilando una griglia da un oggetto entità e sta visualizzando i dati fini. Quando apporto le modifiche e le salvo, nulla si sta aggiornando.datagridview associazione all'entità che non aggiorna il database
Ecco il mio codice:
Nel mio caso in carico:
var query = from c in _entities.PaymentTypes
where c.CorporationId == _currentcorp.CorporationId
select
new DataBindingProjection
{
PaymentTypeId = c.PaymentTypeId,
CorporationId = c.CorporationId,
TokenId = c.TokenId,
IsActive = c.IsActive,
Description = c.Description,
CashChargeCodeType = c.CashChargeCodeType,
SortOrder = c.SortOrder,
ExcludeCreditCode = c.ExcludeCreditCodes,
IsUpdated = c.IsUpdated,
IsAdded = c.IsAdded,
ClearUpdatedAndAdded = c.ClearUpdateAndAdded
};
dataGridView_PaymentTypes.DataSource = query.ToList();
La mia classe:
private class DataBindingProjection
{
public Guid PaymentTypeId { get; set; }
public Guid CorporationId { get; set; }
public Guid TokenId { get; set; }
public bool IsActive { get; set; }
public string Description { get; set; }
public int CashChargeCodeType { get; set; }
public int SortOrder { get; set; }
public int ExcludeCreditCode { get; set; }
public bool IsUpdated { get; set; }
public bool IsAdded { get; set; }
public bool ClearUpdatedAndAdded { get; set; }
}
Nel pulsante per salvare le modifiche:
private void button_SaveChanges2_Click(object sender, EventArgs e)
{
button_SaveChanges2.Enabled = false;
_entities.SaveChanges();
timer1.Enabled = true;
button_SaveChanges2.Enabled = true;
}
Che cosa sto facendo di sbagliato?
In risposta a bmused:
definita a livello di classe:
private SuburbanPortalEntities _entities;
definito nel mio carico:
var bs = new BindingSource();
_entities.PaymentTypes.Where(x => x.CorporationId == _currentcorp.CorporationId).Load;
bs.DataSource = _entities.PaymentTypes.Local.ToBindingList();
dataGridView_PaymentTypes.DataSource = bs;
Si sta dimostrando che esso non può caricare il simbolo di carico e Locale:
Perché stai proiettando ad un altro tipo che ha le stesse identiche proprietà della tua entità? –
test, ho provato diverse idee e ho finito con questo. Certo, non è necessario ma l'ho lasciato. – ErocM
non dovrebbe essere 'Load' be' Load() '? –