Web API ODATA - Does we have to load all the records to enable filtering using Odata? - entity-framework

I am developing an API using ASP.Net WEB API + Odata to query and filter those data. But rather than using entity framework to retrieve data,i am using ADO.Net to get data from Stored Procedures.
Its working fine but to apply Odata filtering first i have to retrieve
all the records from the database. If the table cotains more than 1
million records then the server will just hang.
This is a sample code i am using,
List<ApplicationProduct> res = applicationBL.GetApplicationProducts(key, SyndicateKey);
if (res.Count > 0)
{
Request.ODataProperties().TotalCount = res.Count();
GenarateNextLink(key, res.Count, Convert.ToString(Request.RequestUri).Contains("$top"));
SetCacheDuration(1);
return Ok(res.AsQueryable());
}
So i have to find a way to generate the query dynamically so filters are applied first and then we dont have to load all the records from the database. Is it possible using OData ? Or is there any other way?
Thank You.

Related

CRUD operation Grails

I need to read data from existing database is it possible using
compile "org.grails.plugins:db-reverse-engineer:4.0.0"?
My operations are: user should read data from existing table, create new record, create new coulmn, edit coulmn name, edit records.
View format will be in grid like xml grid.
Which technology is the best for these operations in grails, I have plan to work on javascript using jaxrs, is it good to do?
DB Reverse Engineering Plugin (org.grails.plugins:db-reverse-engineer:4.0.0) allows you to generate domain classes using existing DB. After you generate them - just use GORM to perform CRUD operations. You can read about GORM here
You can implement REST api in Grails using standart ways, check this answer to get high level understanding. If you need jaxrs- there is a plugin for that.

WebApi OData with NoSQL dynamic properties

We are developing an application with a NoSql database (RavenDb or MongoDb).
This data should be exposed as a WebApi Odata` service.
We use metadata that can be used for queries and will not change. However the other data will be very dynamic in time and the structure that is saved will be different in the future.
We cannot implement a change everytime this data structure changes so we want to have some dynamic data in our WebApi.
It is possible in WebApi OData map dynamic properties in a dictionary but is this possible to configure this against a NoSql database?
Example for mongo db data
{"Readings":[
{"DeviceID":"1", "ReadingId":"1", "Reading1":"foo"},
{"DeviceID":"2", "ReadingId":"2", "Reading1":"foo", "Reading2":"bar"},
{"DeviceID":"3", "ReadingId":"3", "Reading2":"This", "Reading3":"That"}
]}
We will need a OData service returning readings with "Reading1", "Reading2", "Reading3". The querying will be performed on "DeviceID" or "ReadingId"
From the devices it could be we will receive "Reading4" and store it flexible. But it will have to be exported next time the OData service is requested.

How to map the parameters while inserting data using IRowMapper?

I am using Microsoft Enterprise Library IRowMapper for getting data and mapping to result set, but is there any possibility of using IRowMapper for inserting data?

How to find the database exist or not with Jaydata Context

I am working on an application with jaydata as ORM and angularjs as middle layer : working with jaydata how can i find with context that whether the DB has already benn created or its the first time it is been created by the code ..>???
You can perform this check only if you verify the number of the records in a specific table that normaly contains data.

EF4 STE include-path....exclude-path?

Context: Repository-pattern, WCF, WPF/SL
In my Repository of self-tracking Entities i need to explicitly load some related properties in order to correctly process the query. Those are not the includes requested by the client and i would like to get rid of them in order to keep network traffic resonable. My solution so far is this:
Receive Query
Load includes necessary to answer request
Execute Query
Create temporary IEnumerable
Iterate 4) and load all items again, this time with the include-path requested from the client-app only
return entities via WCF
I would like to do this:
Receive Query
Load all includes (infrastructure plus client-requested)
Execute Query
Unload "Infrastructure" includes
return entities via WCF
What is the proper way to do this?
Thanks,
Armin
How about lazy loading and proper DTO response objects ?
WCF returns custom Order or GetOrderResponse (Contracts.Order)
Load Order from EntityModel through repository (just the order)
Use automapper for mapping EntityModel.Order => Contracts.Order
Result : only the corresponding properties inside Contracts.Order are loaded:
Ex. Contracts.Order
Number
OrderDetails (=> Only this property is loaded through lazy loading because it is mapped)
If you are building a SOA or webservice, don't let the client specify load graphs. If it's necessary for the client to specify load graphs consider deploying the Model using WCF Data Services, works great.
Perhaps you could build two systems .. one SOA and one (readonly) Data Service.