none
LINQ UNION问题 RRS feed

  • 问题

  • 查询结果中有多个null列,产生的语句是错误的,请问这样的怎么解决。

    代码: 

    return (from task in fiterTasks
                        select new SelectListItem()
                            {
                                ItemTitle = task.Title,
                                ItemTaskID = task.TaskID,
                                ItemPlugInSetupID = null,
                                Tag = null
                            }).Concat(

                    from plug in fiterPlug
                    select new SelectListItem()
                        {
                            ItemTitle = plug.PlugInCName,
                            ItemTaskID = null,
                            ItemPlugInSetupID = plug.ID,
                            Tag = plug.Tag
                        }
                    );

    产生的sql:

    exec sp_executesql N'SELECT COUNT(*) AS [value]
    FROM (
        SELECT [t0].[Title], [t0].[TaskID], @p1 AS [value]
        FROM [publisher].[Task] AS [t0]
        WHERE [t0].[IsEnabled] = @p0
        UNION ALL
        SELECT [t1].[PlugInCName], NULL AS [value], [t1].[ID] AS [value2], [t1].[Tag]
        FROM [publisher].[PlugInSetup] AS [t1]
        ) AS [t2]',N'@p0 int,@p1 int',@p0=1,@p1=NULL

    2012年4月26日 8:23