I would like to select only few columns from a certain (Blobs) table. I have fields like: Id, RowVersion, Size, Signature, Blob, and I want to select only first four. I do it like this: (---> is an error place)
public List<BlobDetails> GetAllBlobsNames()
{
RichTekstModelDataContext dc = new RichTekstModelDataContext();
var allBlobs = from b in dc.Blobs
orderby b.RowVersion descending
select new {b.Id, b.Size, b.Signature, b.RowVersion};
---> allBlobs.ToList<BlobDetails>();
}
public class BlobDetails
{
public int Id { get; set; }
public string Signature { get; set; }
public int Size { get; set; }
public System.Data.Linq.Binary RowVersion { get; set; }
}
Error occures when I am trying to return BlobDetails - as VS.08 doesn't know how to convert from Anonymous Type (allBlobs) to List.
I do not want to select all values, because Blob field can be quite heavy and I don't want to send it all the time.
Do you have any idea how to do it properly?
I hope I am clear on my issue.