I have a database with primary key Auto increment id when a send a get request to web api I want to filter datas by specified columns equals something. When i tried this in SSMS its working Select top 1000 from [dbo.][ogrencisonuclar] where kullaniciid='1'
But How can i do this request by web api ? I'm using entity framework. When I requested datas filtering by primary key id not kullaniciid..
This is code on my web api
public ogrencisonuclar Get(int ID)
{
using (denemetabloEntities entities = new denemetabloEntities())
{
ogrencisonuclar sonuc = entities.ogrencisonuclar.Find(ID);
return sonuc;
}
}
This is the code on Xamarin to request datas by kullaniciid;
var client1 = new RestClient("http://mikrontasarim.somee.com/api/ogrencisonuclar/Get/" + kullid);
client1.Timeout = -1;
var request1 = new RestRequest(Method.GET);
var response1 = client1.Execute<List<Models.sonucagecismodeli>>(request1);
List<Models.sonucagecismodeli> events = response1.Data;
Find
always queries by the PK. You can use a LINQ query to query on other parameters
ogrencisonuclar sonuc = entities.ogrencisonuclar.Where(x => x.kullaniciid == ID).FirstOrDefault();
to fetch all matching rows
ogrencisonuclar sonuc = entities.ogrencisonuclar.Where(x => x.kullaniciid == ID).ToList();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.