我的以下代码有问题:

    private void DataPortal_Fetch(TaskCriteria criteria)
    {
        using (var ctx = ContextManager<Gimli.Data.GimliDataContext>
                    .GetManager(Database.ApplicationConnection, false))
        {
            this.RaiseListChangedEvents = false;
            this.IsReadOnly = false;

            IQueryable<Data.Task> query = ctx.DataContext.Tasks;

            if (criteria.ReadyForPricing)
            {
                query = query.Where(row => row.IsPriced != true);
                query = query.Where(row => row.Status == (int)TaskStatus.Closed);
                query = query.Where(row => row.InvoiceId == Guid.Empty);
            }

            if (criteria.ReadyForInvoicing)
            {
                query = query.Where(row => row.IsPriced == true);
                query = query.Where(row => row.Status == (int)TaskStatus.Closed);
                query = query.Where(row => row.InvoiceId == Guid.Empty);
            }

            var data = query.Select(row => TaskInfo.FetchTaskInfo(row));

            this.AddRange(data);

            this.IsReadOnly = true;
            this.RaiseListChangedEvents = true;
        }
    }


如果我不注释以下行,则我的Web应用程序调用此方法时始终挂起:

query = query.Where(row => row.InvoiceId == Guid.Empty


知道为什么会这样吗?

最佳答案

以下代码可以正常工作...有趣的是...为什么要这样做?

query = query.Where(row => row.InvoiceId == new Guid("00000000-0000-0000-0000-000000000000"));

关于c# - 在where表达式中使用Guid.Empty挂起Linq查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/358345/

10-13 07:48