Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将SQL查询转换为实体框架核心C#代码?_C#_Mysql_Entity Framework - Fatal编程技术网

如何将SQL查询转换为实体框架核心C#代码?

如何将SQL查询转换为实体框架核心C#代码?,c#,mysql,entity-framework,C#,Mysql,Entity Framework,我有一个SQL查询,我必须在实体框架中工作。如何将下面的查询转换为实体框架可以使用的内容 我看过entity.THcp.FromSqlRaw的用法,但它不喜欢这样,因为它说我已经有多个hcp_ID了 我使用的是MySQL,因此无法使用Linqer() 下面是SQL: SET @territory = 'A1234'; SELECT * FROM t_hcp LEFT JOIN t_contactinfo ON t_hcp.HCP_ID = t_contactinfo.HCP_ID INNER J

我有一个SQL查询,我必须在实体框架中工作。如何将下面的查询转换为实体框架可以使用的内容

我看过entity.THcp.FromSqlRaw的用法,但它不喜欢这样,因为它说我已经有多个hcp_ID了

我使用的是MySQL,因此无法使用Linqer()

下面是SQL:

SET @territory = 'A1234';
SELECT *
FROM t_hcp
LEFT JOIN t_contactinfo ON t_hcp.HCP_ID = t_contactinfo.HCP_ID
INNER JOIN t_zipterr on t_contactinfo.zip = t_zipterr.Zip
LEFT JOIN t_contactinfo_email ON t_contactinfo.HCP_ID = t_contactinfo_email.HCP_ID
LEFT JOIN t_watson ON t_contactinfo_email.Email_ID = t_watson.Email_ID
LEFT JOIN lt_hcp_specialty ON t_hcp.HCP_ID = lt_hcp_specialty.HCP_ID
LEFT JOIN t_hcp_specialty ON lt_hcp_specialty.specialty_ID = t_hcp_specialty.specialty_ID
LEFT JOIN lt_hcp_brand ON t_hcp.HCP_ID = lt_hcp_brand.HCP_ID
LEFT JOIN t_brand ON lt_hcp_brand.brand_id = t_brand.brand_id
WHERE t_hcp._utc_deleted IS NULL
AND (Terr = @territory
        OR Region = @territory
        OR MDM_Terr = @territory
        OR Zone = @territory
        OR RAD_ID = @territory
        OR RRD_Terr = @territory
);