4
Follows code:
using (var db = new Entities())
{
var result = db.
Tabela1
.Where(x => x.Id == 1)
.Select(x => new SuaClasse
{
Coluna1 = x.Coluna1,
})
.FirstOrDefault();
if (result.Coluna1 != string.Empty)
{
result.Coluna2 = "Novo valor";
}
var num = db.SaveChanges(); // aqui retorna 0
}
Class:
public class SuaClasse
{
public string Coluna1 { get; set; }
public string Coluna2 { get; set; }
}
I just want to select a column and then update column value2, nothing happens, only returns 0. What I did wrong ?
@Matheusmiranda this varbinary is image ? file ? by what I’ve been reading, to get around this problem you should put this property in another entity, even if it is 1:1. Then it is more a matter of your need... whether it is easier to make another entity or use the query. Vlw
– Rovann Linhalis