Introduction

This article explains OData Security Guidance. It gives some security options that we can use when we expose a dataset using ODATA.
It defines the types of security that are as follows:

EDM security

The EDM model depends on the entity model. It is not an implicit type of model. If there is a need for ignoring any property from the EDM, then we use the [IgnoreDataMember] attribute. When we use this attribute the property is not visible in the EDM. Now here we see an example of class "Customer" that has various properties such as "name", "address" and "Contact_no". If we want that the "Contact_no" property is the EDM then we can exclude it by using [IgnoreDataMember].

  1. public class Customer
  2. {
  3. public string Name { get; set; }
  4. public string Title { get; set; }
  5. [IgnoreDataMember]
  6. public decimal Salary { get; set; }
  7. }

There is another way to exclude the property from the EDM.

  1. var customer = modelBuilder.EntitySet<Customer>("Employees");
  2. employees.EntityType.Ignore(cust => cust.Contact_no);
  3. }

In the query security, the query is converted and implemented through an action filter that is the [Queryable] attribute. It is based on the LINQ expression that is found by parsing the Query in the LINQ expression. And again the LINQ expression is parsed into a Query option through the IQueryable LINQ provider that is returned though the OData Controller. And it also depends on the distinct feature of the database.

If you believe your clients or database is small, then the performance of the Query is not an issue. Or as you can use these references:

[Queryable(PageSize = 8)]

  1. public IQueryable<Item> Get()
  2. {
  3. return items.AsQueryable();
  4. }

OData is created to only be implemented as an OData specification that has the requirement for it target scenerio.