Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Most efficient way to get one column from appbinaryobjects table? #11118


User avatar
0
marble68 created

Prerequisites

Core MVC v11.0

I have an entity with a file property, which the system puts in appbinaryobjects table.

When getting results, the created service goes and gets each binaryobject and then only uses the description. This is extremely slow.

So I'm doing this:

desc = _binaryObjectRepository.Get(id).Description;

This has helped - is there a better way to do this? I see there's a .Query on the IRepository - but I'm not sure how to use it.

Any faster way you might suggest?

EDIT

I found the best way: desc = _binaryObjectRepository.Query<string>(q => q.Where(r => r.Id == id).Select(r => r.Description).FirstOrDefault());

In the above example, it still seleted all columns. The above generates a query similar to this (mysql):

select a.Descriptions from AppBinaryObjects as a where (false or (a.TenantId=5213)) AND (a.Id = '<guid>') limit 1


No answer yet!