I want to know if it is possible to choose what column I want to compare Datetime value depending on another column's value, for example:
My model looks like this:
public class ServicosFinanceiro
{
[Key]
public int IdservFin { get; set; }
public int? ParcelaAtual { get; set; }
public DateTime? DataVencto1 { get; set; }
public DateTime? DataVencto2 { get; set; }
public DateTime? DataVencto3 { get; set; }
public DateTime? DataVencto4 { get; set; }
}
I want to select with linq to sql the rows that are in the datetime range of DataVencto1 or DataVencto2 or DataVencto3 or DataVencto4 according to the ParcelaAtual value.
If ParcelaAtual = 1 i need to compare the date of DataVencto1 column. If ParcelaAtual = 2 i need to compare the date of DataVencto2 column and so on..
Currently I'm selecting all the rows and doing a foreach to check what is ParcelaAtual value and according to it I select compare the date range of the respective DataVencto column and add it to another model object.
Is it possible to achieve that on the select statement using linq to sql?