I've got the following 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 have found that when requesting data from the webApi, if the fields are null then the returning JSON result doesn't include that field in the return result. Is this expected behaviour?