Witam,
mam 3 klasy:
[Table("Firmy"]
public class Firma
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int FirmaId{ get; set; }
[MaxLength(150), Required]
public string Nazwa { get; set; }
[MaxLength(50), Required]
[DisplayName("Nazwa skrócona")]
public string NazwaKrotka { get; set; }
public int? Telefon { get; set; }
public int? Fax { get; set; }
[MaxLength(150)]
public string Ulica { get; set; }
//[MaxLength(5)]
public int Kod { get; set; }
[MaxLength(150)]
public string Miasto { get; set; }
[MaxLength(150), Required]
[DisplayName("E-mail")]
public string Email { get; set; }
public bool Aktywny { get; set; }
public virtual ICollection<FirmaOddzialHistoria> Oddzialy { get; set; }
}
[Table("FirmyOdddzialyHistoria")]
public class FirmaOddzialHistoria
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int FirmaOddzialHistoriaID { get; set; }
public virtual Firma Firma { get; set; }
public virtual FirmaOddzial FirmaOddzial { get; set; }
public DateTime DataStart { get; set; }
public DateTime DataKoniec { get; set; }
}
[Table("FirmyOddzialy"]
public class FirmaOddzial
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int OddzialId{ get; set; }
public int? Telefon { get; set; }
public int? Fax { get; set; }
[MaxLength(150)]
public string Ulica { get; set; }
[MaxLength(5)]
public string Kod { get; set; }
[MaxLength(150)]
public string Miasto { get; set; }
[MaxLength(150), Required]
public string Email { get; set; }
public bool Aktywny { get; set; }
public virtual ICollection<FirmaOddzialHistoria> Firmy { get; set; }
public virtual ICollection<UzytkownikHistoria> Uzytkownicy { get; set; }
public Limit Limit { get; set; }
}
W kontrolerze(MVC) chcę pobrać wszystkie oddziały należące w chwili obecnej do określonej firmy czyli powinienem zrobić coś takiego:
repository.FirmyOddzialy.Where(p => p.Firmy.DataStart<=DateTime.Now && p.Firmy.DataStop>=DateTime.Now && p.Firmy.Firma.FirmaId==1)
niestety z jakiegoś powodu VS nie widzi właściwości DataStart, DataStop, itd.Jakieś pomysły jak rozwiązać ten problem?
Będę wdzięczny za wszelkie podpowiedzi.