How can I fetch a single field from the table change it and save this field without having to fetch all fields from the table?
The reason for this is simple, I have some tables that have more than 30 columns and this has a high cost of processing in the application when the times are updated only one field of this table, as in the example below, I have the Cities table and I just need to change the name of the city, how could I search and change only the Name field?
Obs ; I am using system.data.linq.datacontext my context is like this.
public System.Data.Linq.Table<Tabela_ScanImagen> Tabela_ScanImagens
{
get
{
return this.GetTable<Tabela_ScanImagen>();
}
}
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Tabela_ScanImagens")]
public partial class Tabela_ScanImagen : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private double _Imagem;
private string _Path;
private System.Nullable<double> _Cliente;
private System.Nullable<double> _Orcamento;
private System.Nullable<double> _Documento;
private System.Nullable<double> _Alteracao;
private System.Nullable<double> _Sinistro;
private System.Nullable<double> _Seguradora;
private System.Nullable<double> _Divisao;
private string _Descricao;
}
I tried to do it using the EntityFramework.Extended package, but it only accepts the context being System.Data.Entity
DbContext
public void Salvar()
{
using (var dm = new DmContext())
{
var _descricao = dm.Tabela_ScanImagens
.Where(c => c.Imagem == 6)
.Select(c => c.Descricao)
.FirstOrDefault();
dm.Tabela_ScanImagens.Update(c => new Tabela_ScanImagen { Descricao = "teste" });
dm.SaveChanges();
}
}
That way it returns me the following error.
The query must be of type ObjectQuery or DbQuery. Parameter name: source