I'm trying to select a single property [filename] into a List out of a ICollection where dr405 has many properties.
return GetDR405ById(c, id).dr405files.Select(p => p.FileName).ToList<String>();
public class dr405files
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int FileId { get; set; }
public String TangiblePropertyId { get; set; }
public String FileName { get; set; }
public DateTime? UploadDate { get; set; }
public Byte[] FileData {get;set;}
public long? FileLength { get; set; }
}
I want the SQL equivalent of SELECT [Column1] FROM [Table1]
as opposed to `SELECT * FROM [Table1]
I think you just want to do
return GetDR405ById(c, id).Select(p => p.FileName).ToList();
unless GetDR405ById
really does return an object that has a property called dr405files that is a generic collection of dr405files objects.
EDIT.
Notice i have also removed the generic type param from ToList(). Filename is a string so T will be infered by the compiler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With