我在我的网页API有以下以下命令:
return Request.CreateResponse(HttpStatusCode.OK,
MyDBContext.DB.Database.SqlQuery<MyCustomerClass>("SELECT * FROM CUSTOMER").ToList());
下面是表:
CREATE TABLE [dbo].[Customer] (
[CustomerID] [int] NOT NULL,
[FirstName] [nvarchar](50) NOT NULL,
[LastName] [nvarchar](50) NULL,
CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED
([CustomerID] ASC) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON [PRIMARY]
) ON [PRIMARY]
GO
我发现,从请求的WebAPI数据时,如果该字段为null
,则返回JSON结果不包括在返回结果的那场。 这是预期的行为?