Mobile Service with .Net Backend - API issue
hi,
i have created mobile service .net backend sql azure database having table called customers.
on have created api return list of customers json.
for testing purpose have inserted customers info into the local mdf file get along with the service project.
when publish service project locally api returning list of customers (from local database file) with out problems.
so, published service project mobile service. after publishing, tried call api list of customers but i getting error below.
the customer table(in azure) having 100 thousands of records. after research found issue number of records. when table having less records api working fine if table having thousands of records failing.
my requirement want call api having business logic having multiple tables performing joins on tables , returning records application.
note: each table having thousands of records.
api logic using is:
if use below query less number of records working:
var result = database.sqlquery<customer>("select * fstmobileservice.customer account_number ='wimid2271'").tolist<customer>();
if try customers failing.
var result = database.sqlquery<customer>("select * fstmobileservice.customer").tolist<customer>();
the api failing single table records, then how can i achieve below:
public class populatecustomerscontroller : apicontroller { public apiservices services { get; set; } observablecollection<populatecustomers> populatecustomers = new observablecollection<populatecustomers>(); // api/populatecustomers public string get() { services.log.info("hello custom controller!"); string customersjson = ""; using (fstmobileservicecontext context = new fstmobileservicecontext()) { // database context. var database = context.database; //var result = database.sqlquery<customer>("select * fstmobileservice.customer account_number ='wimid2271'").tolist<customer>(); //var result1 = context.set<customer>().sqlquery("select * fstmobileservice.customer account_number ='wimid2271'").tolist<customer>(); //var result = bob in context.customers select bob; //var book_of_businesslist = bo in context.book_of_business bo.employee_id == employeeid select bo; //var customertbl = bo in context.book_of_business bo.employee_id == employeeid select bo; var query = bob in context.book_of_business join customer in context.customers on bob.account_number equals customer.account_number bob.employee_id == "0042469" join addtype in context.address_type on customer.account_number equals addtype.account_number addtype.addresstype == "default" join add in context.addresses on addtype.address_id equals add.address_id select new { account_number = customer.account_number, address_line_1 = add.address_line_1, address_line_2 = add.address_line_2, address_line_3 = add.address_line_3, city = add.city, country = add.country, customer_name = customer.customer_name, description = add.description, employee_id = bob.employee_id, postal_code = add.postal_code, sales_tier = customer.sales_tier, state = add.state, zone_id = customer.zone_id, address = add.address_line_1 + "," + add.city + "," + add.state + "," + add.country }; populatecustomers = new observablecollection<populatecustomers>(); foreach (var item in query) { populatecustomers.add(new populatecustomers() { account_number = item.account_number, address_line_1 = item.address_line_1, address_line_2 = item.address_line_2, address_line_3 = item.address_line_3, city = item.city, country = item.country, customer_name = item.customer_name, description = item.description, employee_id = item.employee_id, postal_code = item.postal_code, sales_tier = item.sales_tier, state = item.state, zone_id = item.zone_id, address = item.address_line_1 + "," + item.city + "," + item.state + "," + item.country }); } var customersrootobject = new customersrootobject(); customersrootobject.customerscollection = populatecustomers.tolist<populatecustomers>().toarray(); customersjson = jsonconvert.serializeobject(customersrootobject); return customersjson; } } }
can tell me how can i achieve kind of scenario?
my primary question is
how customers (thousands of customers info) info through api.
go mobile service panel , check log, errors appear? can helpful.
regards
Microsoft Azure > Azure Mobile Apps
Comments
Post a Comment