Hello,
I have thesse classes that i use to retrieve from the database using snapobjects:
[FromTable("customers")]
public class Customer
{
[Key]
[SqlColumn("customers", "id")]
public int Id { get; set; }
[ModelEmbedded(typeof(Contact), ParamValue = "$Id" CascadeCreate = false, CascadeDelete = false)]
public List Contacts { get; set; }
}
[SqlParameter("CustomerId", typeof(string))]
[FromTable("contacts")]
[SqlWhere("id = :CustomerId")]
public class Contact
{
[Key]
[SqlColumn("contacts", "id")]
public int Id { get; set; }
[ModelEmbedded(typeof(Contact), ParamValue = "$Id" CascadeCreate = false, CascadeDelete = false)]
public List Comms { get; set; }
}
[SqlParameter("ContactId", typeof(string))]
[FromTable("communications")]
[SqlWhere("id = :ContactId")]
public class Communication
{
[Key]
[SqlColumn("communications", "id")]
public int Id { get; set; }
}
How can i include the list "comms", not using .includeAll(). Because i have to conditionally add the Comms.
Ex:
var result = _dataContext.SqlModelMapper.Load();
if(addContacts)
{
result.Include(el => el.Contacts);
}
if (addContactsComms)
{
}
What do i need to add in the second if statement to work.
result.Include(el => el.Contacts.Comms); does not work because "Comms" is a list
Kind regards,
Aaron D'Hooghe