I have the following command in my web api:
return Request.CreateResponse(HttpStatusCode.OK, MyDBContext.DB.Database.SqlQuery<MyCustomerClass>("SELECT * FROM CUSTOMER").ToList());
Here is the table:
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
I found that when requesting data from webApi, if the fields are null , then the returned JSON result does not include this field in the return result. Is this expected behavior?
source share