I'm using a Linq DataContext.ExecuteQuery("some sql statement") to populate a list of objects
var incomes = db.ExecuteQuery<IncomeAggregate>(sqlIncomeStatement(TimeUnit));
The IncomeAggregate
is an object I made to hold the result of the records of this query.
One of the properties of this object is YQM:
public int Year { get; set; }
public int Quarter { get; set; }
public int Month { get; set; }
public string YQM
{
get { return string.Format("Y{0}-Q{1}-M{2}", Year, Quarter, Month); }
}
... more properties
Everything compiles OK, but when it executes the Linq I get the following error:
Cannot assign value to member 'YQM'. It does not define a setter.
But clearly, I don't want to 'set' it. Y, Q and M are provided by the query to the database. YQM is NOT provided by the query. Do I need to change the definition of my object somehow? (I've just started using Linq and I'm still getting up to speed, so it could be very simple)
private set { ;}
– Alemanprivate set { ;}
solution. – Czardas