
/****** Object:  View [dbo].[ApiPictureView]    Script Date: 13.09.2021 15:19:00 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO






CREATE VIEW  [dbo].[ApiPictureView] as


select a.ID , a.Parent  , MimeType  ,0 ParentType, ParentType ParentTypeName, Name, 
convert(nvarchar(50), u.Guid) Guid
 from dbo.Attachments  a 
 JOIN dbo.Urzadzenia u ON u.ID = a.Parent
where /*MimeType = 'image/pjpeg' and */
ParentType = 'Urzadzenia'
UNION
select  a.ID , a.Parent  , MimeType  ,0 ParentType, ParentType ParentTypeName, Name, 
convert(nvarchar(50), t.Guid) Guid
 from dbo.Attachments  a 
 JOIN dbo.Tuples t ON t.ID = a.Parent
where 
/*MimeType = 'image/pjpeg' and */
ParentType = 'Tuples'

UNION
select a.ID, a.Parent , MimeType  ,0 ParentType, ParentType ParentTypeName, Name, 
convert(nvarchar(50), z.Guid) Guid
 from dbo.Attachments  a 
 JOIN dbo.Zadania z ON z.ID = a.Parent
where 
/*MimeType = 'image/pjpeg' and */
ParentType = 'Zadania'

UNION

select a.ID, a.Parent , MimeType  , 0 ParentType, ParentType ParentTypeName, Name, 
convert(nvarchar(50), z.Guid) Guid
 from dbo.Attachments  a 
 JOIN dbo.Technologie z ON z.ID = a.Parent
where 
/*MimeType = 'image/pjpeg' and */
ParentType = 'Technologie'





GO


