in the C# code there is no secondaryId column it uses CompanyId and it matches to ProductCompanyId.
direct translation:
declare @id int;
declare @companyId int = (select top 1 CompanyId from Products where id = @id and Active = 1);
if @@rowcount > 0
begin
select *
from Products
where id = @id and Active = 1 and ProductCompanyId = @companyId
end
and with ties:
declare @id int;
select top(1) with ties
from Products
where id = @id and Active = 1 and ProductCompanyId = companyId
order by companyId