I have this class:
public class Userinfo
{
public Userinfo()
{
}
public static async Task<List<Information>> Login(string Username, string Password)
{
string str = "https://somesite.com/log.php";
string[] cID = new string[] { "act=qwjFpPXuGexZBHDJEreZrAUH&CID=", "&username=", Username, "&password=", Password };
string str1 = string.Concat(cID);
using (WebClient webClient = new WebClient())
{
webClient.Proxy = null;
webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string str2 = webClient.UploadString(str, str1)
var result = JsonConvert.DeserializeObject<List<Information>>(str2);
return result;
}
}
}
Which returns this JSON
[{"username":"fakeuser","email":"fakeemail#outlook.com","plan":"1","activationdate":"18\/12\/20","terminationdate":"18\/01\/21"}]
What I want to do is set in another form the data inside the result variable in labels so they can display the actual content. The problem is that if I debug the code the variable seems to be empty. If I make a break and hover the mouse over the variable it doesn't show anything and it doesn't even appear on the variable list. So, what am I doing wrong?
This is the code I have in the form where I have the labels:
private async void Filldata()
{
var result = await Userinfo.Login("username", "password");
label11.Text = result.Select(x => x.username).FirstOrDefault();
label18.Text = result.Select(x => x.email).FirstOrDefault();
label19.Text = result.Select(x => x.plan).FirstOrDefault();
label20.Text = result.Select(x => x.activationdate).FirstOrDefault();
label21.Text = result.Select(x => x.terminationdate).FirstOrDefault();
}
And here is my class where I deserialize the JSON:
public class Information
{
public string username { get; set; }
public string email { get; set; }
public string plan { get; set; }
public string activationdate { get; set; }
public string terminationdate { get; set; }
}
I think it's worth mentioning that the classes are separate. Userinfo and Information are their own classes.
What am I missing and how can I solve this?
Posted again because I haven't been able to solve this.
Related
I am very new to C#. I am writing a program using visual studio c# where it will first ask the user to enter an employee name. Next, it will pass that name through an API and will retrieve and display the employee signature. I have completed this portion.
Next, the program will ask the user to enter a designated "to" and "from" date. Next, the program should pass the date information as well as the signature obtained previously through a second API and retrieve and display information on to a grid data table accordingly.
For the Grid view data table, I understand that I should be connected to a SQL data server, which I am.
My problem is that
I am not sure how to write a code which will pass three parameters to an API (the "to" and "from" date, and the employee signature). I have tried the code below, however, I receive an error when I try to link the corresponding button to the JSON code to retrieve data. The error states that
"There is no argument given that corresponds to the required formal
parameter 'toDate' of 'WebAPI.GetTime(double, double, string).'
I am not sure how to pass the signature previously obtained from a different API through the new API.
Any help would be much appreciated.
Code for defining the JSON variables:
namespace TimeSheet_Try11_Models
{
// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
public class OracleHour
{
public string orderNumber { get; set; }
public DateTime dateOfWork { get; set; }
public string description { get; set; }
public string surveyor { get; set; }
public string hourType { get; set; }
public double hours { get; set; }
public int status { get; set; }
public string savedInOlsonTimezone { get; set; }
public double invoicelinevalue { get; set; }
public string articleType { get; set; }
public DateTime dateOfWorkInSavedTimezone { get; set; }
}
public class MyArray
{
public string orderNumber { get; set; }
public string projectnumber { get; set; }
public string noteToInvoicer { get; set; }
public List<object> oracleCosts { get; set; }
public List<OracleHour> oracleHours { get; set; }
}
public class Root1
{
public List<MyArray> MyArray { get; set; }
}
}
Code calling out the JSON:
namespace TimeSheets_Try_11.Controllers
{
class WebAPI
{
public string[] GetTime(double fromDate, double toDate, string username)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var cookies = FullWebBrowserCookie.GetCookieInternal(new Uri(StaticStrings.UrlNcert), false);
WebClient wc = new WebClient();
wc.Encoding = System.Text.Encoding.UTF8;
wc.Headers.Add("Cookie:" + cookies);
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
wc.UseDefaultCredentials = true;
string url = "";
url = $"{StaticStrings.UrlNcert}?user={username}&fromDate={fromDate:yyyy-MM-dd}&toDate={toDate:yyyy-MM-dd}";
var respons = wc.DownloadString(url);
OracleHour ndata = JsonConvert.DeserializeObject<OracleHour>(respons);
var Get_Odnum = ndata.orderNumber;
var Dt_Work = ndata.dateOfWork;
var hrType = ndata.hourType;
var hr = ndata.hours;
var des = ndata.description;
var surname = ndata.surveyor;
string[] myncertdata = { Get_Odnum, Dt_Work.ToString(), hrType, hr.ToString(), des, surname };
return myncertdata;
}
}
Partial code attempting to connect the corresponding button to retrieve data (the error appears at the very last line):
namespace TimeSheets_Try_11
{
public partial class Form3 : Form
{
WebAPI WA = new WebAPI();
public Form3()
{
InitializeComponent();
webBrowser2.Url = new Uri(StaticStrings.UrlNcert);
}
private void Form3_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'timesDataSet.NCert_Data' table. You can move, or remove it, as needed.
this.nCert_DataTableAdapter.Fill(this.timesDataSet.NCert_Data);
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void GtData_Click(object sender, EventArgs e)
{
var connetionString = ConfigurationManager.ConnectionStrings["Times"].ConnectionString;
try
{
using (SqlConnection conn = new SqlConnection(connetionString))
{
using (SqlCommand cmd = new SqlCommand())
{
conn.Open();
using (SqlCommand Sqlcmd = new SqlCommand("NCert_Data", conn))
{
Sqlcmd.CommandType = CommandType.StoredProcedure;
int counter; string projectnumber; double hrs; string respname; string describe; string[] prjstat; DateTime dates;
for (counter = 0; counter < (dataGridView1.RowCount) - 1; counter++)
{
hrs = 0;
projectnumber = dataGridView1.Rows[counter].Cells[1].Value.ToString();
prjstat = WA.GetTime(projectnumber);
}
}
}
}
}
}
}
public string[] GetTime(double fromDate, double toDate, string username)
needs 3 parameter but
prjstat = WA.GetTime(projectnumber);
has only one...?
Looks like you have to add 2 more parameters
prjstat = WA.GetTime((double), (double), "text");
double fromDate, but you have "projectnumber" a .toString() ...?
Without knowing how the structure of your table looks like there is no way to know what the parameters are. How ever I think your function call should look like this:
prjstat = WA.GetTime((double)dataGridView1.Rows[counter].Cells["fromDate"], (double)(double)dataGridView1.Rows[counter].Cells["toDate"], dataGridView1.Rows[counter].Cells["username"].toString());
Where ["fromDate"], ["toDate"] and ["username"] should be the correct indexes of your expected data.
You may could loop through the cols and output the data with something like that:
for (counter = 0; counter < (dataGridView1.RowCount) - 1; counter++)
{
for (int i = 0; i < dataGridView1.Columns.Count, i++)
{
if (dataGridView1.Columns[i].HeaderText != null) {
System.Console.WriteLine(dataGridView1.Columns[i].HeaderText);
}
System.Console.WriteLine(dataGridView1.Rows[counter].Columns[i].ValueType.ToString());
System.Console.WriteLine(dataGridView1.Rows[counter].Columns[i].Value.ToString());
}
if (counter == 2) { break; }
}
Or just give some dummy values and look what happens ( :P ):
prjstat = WA.GetTime(0, 0, "bla");
Edit: Please note that .Value can be different types like numbers colors dates or what ever. So you have to cast it to a type (double) or use Convert.XYZ. By ValueType.toString() you maybe know what type it is. Or you already know it at all, no idea... ;)
...should pass the date information as well as the signature obtained previously through a second API and retrieve and display information on to a grid data table accordingly.
Well now I'm confused. Could you clarify if you want to store data received by WA.GetTime to dataGridView1 or do you want to send data to WA.GetTime obtained by the dataGridView1?
Btw.: A DataGridView do not "require" an sql database. It can also use xml as example.
I'm trying to display the data from SQL server using web API, get method on edit text in Xamarin.Android. The data will display on the edit text once the button is clicked. I've followed all the steps (exactly) as in the YouTube tutorial but unfortunately, the data did not show up on the edit text, instead it shows JSON format on the screen. What should I do to fix this problem?
I've tried using Web services, still didn't show up.
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.PersonalInfo);
ActionBar.SetDisplayHomeAsUpEnabled(true);
EditText email = FindViewById<EditText>(Resource.Id.txtEmail);
EditText firstName = FindViewById<EditText>(Resource.Id.txtFirstName);
EditText lastName = FindViewById<EditText>(Resource.Id.txtLastName);
EditText gen = FindViewById<EditText>(Resource.Id.txtGender);
EditText ic = FindViewById<EditText>(Resource.Id.txtIC);
EditText address = FindViewById<EditText>(Resource.Id.txtAddress);
EditText phoneNo = FindViewById<EditText>(Resource.Id.txtPhoneNo);
EditText username = FindViewById<EditText>(Resource.Id.txtUsername);
EditText password = FindViewById<EditText>(Resource.Id.txtPwd);
EditText payment = FindViewById<EditText>(Resource.Id.txtPayMethod);
Button btnGetAcc = FindViewById<Button>(Resource.Id.btnGetAcc);
btnGetAcc.Click += async delegate
{
VehicleRecord vehicRec = null;
HttpClient client = new HttpClient();
string url = "http://192.168.0.135/PMSAPI/api/clients/" + username.Text.ToString();
var result = await client.GetAsync(url);
var json = await result.Content.ReadAsStringAsync();
try
{
vehicRec = Newtonsoft.Json.JsonConvert.DeserializeObject<VehicleRecord>(json);
if (vehicRec == null)
{
//check for an array just in case
var items = JsonConvert.DeserializeObject<VehicleRecord[]>(json);
if (items != null && items.Length > 0)
{
vehicRec = items[0];
}
}
}
catch (Exception ex) { }
};
}
The expected output should display data from SQL server on edit text but the actual output is it display all the data in JSON-format.
The actual output:
The logic of your code is to show the JSON if vehicRec == null.
The JSON shown in the image is that of an array. Notice the [] square brackets wrapping the JSON object.
[{....}]
This would mean that asking to deserialize to an object would fail. Refactor the code to desrialize to an array and then extract the desired object out of the result.
//...omitted for brevity
var json = await result.Content.ReadAsStringAsync();
try {
vehicRec = Newtonsoft.Json.JsonConvert.DeserializeObject<VehicleRecord>(json);
if(vehicRec == null) {
//check for an array just in case
var items = JsonConvert.DeserializeObject<VehicleRecord[]>(json);
if(items != null && items.Length > 0) {
vehicRec = items[0];
}
}
}
catch (Exception ex) { }
if (vehicRec == null)
{
Toast.MakeText(this, json, ToastLength.Short).Show();
}
else
{
firstName.Text = vehicRec.firstName;
lastName.Text = vehicRec.lastName;
gen.Text = vehicRec.gender;
ic.Text = vehicRec.icNo;
address.Text = vehicRec.address;
phoneNo.Text = vehicRec.phoneNo;
username.Text = vehicRec.username;
password.Text = vehicRec.password;
payment.Text = vehicRec.paymentMethod;
}
//...omitted for brevity
Note also in the JSON that there are multiple items in the array. I would suggest you consider using a list to display the records in the array.
The code above will only show the first item in the array but can be easily refactored to use the array as a data source for a list view.
It was also noted that the names of the fields in the JSON do not match that of the class being populated. Which will cause the properties to not get any values.
From one of your previous questions I was able to see that you defined the class as
public class VehicleRecord {
public string firstName { get; set; }
public string lastName { get; set; }
public string gender { get; set; }
public string icNo { get; set; }
public string address { get; set; }
public string phoneNo { get; set; }
public string email { get; set; }
public string username { get; set; }
public string password { get; set; }
public string plateNo { get; set; }
public string model { get; set; }
public string col { get; set; }
public string paymentMethod { get; set; }
}
But the JSON shown in the image has all fields prefixed with a cl.
You would need to add a mapping so the JsonConverter knows how to populate the class
public class VehicleRecord {
[JsonProperty("clFirstName")]
public string firstName { get; set; }
[JsonProperty("clLastName")]
public string lastName { get; set; }
[JsonProperty("clGender")]
public string gender { get; set; }
//...etc
}
You may be better off using a JSON parser to generate the class for you which would also include the attributes to map the properties.
Hey all so here is the JSON string I expect back {\"status\":\"success\",\"locations\":[{\"id\":\"24\",\"name\":\"Test New Location Test\",\"contact_first_name\":\"Test\",\"contact_last_name\":\"Test\",\"contact_email\":\"test#email.com\",\"contact_phone_number\":\"(555) 555-5555\",\"billing_address\":\"Test\",\"billing_city\":\"Test\",\"billing_state\":\"AK\",\"billing_zip\":\"55555\",\"traps\":[]}]}
I am trying to store all the different parts that make up a location to an object list such as id, name, contact_first_name etc.. I think what is tripping me up is the status in front that is making it a little more difficult for me access the different locations.
I am following this tutorial that seems pretty clear but haven't gotten it to work on my end yet. https://www.youtube.com/watch?v=XssLaKDRV4Y
The below code is part of my Service class and it works in getting the expected http response (mentioned above) and getting the success message. When I uncomment the few lines of code below my app breaks and doesn't store any objects to a list.
public async Task<string> GetLocationData()
{
var user_id = Convert.ToString(App.Current.Properties["user_id"]);
var session = Convert.ToString(App.Current.Properties["session"]);
var key = "randomkeystring";
var body = new List<KeyValuePair<string, string>>();
body.Add(new KeyValuePair<string, string>("user_id", user_id));
body.Add(new KeyValuePair<string, string>("session", session));
body.Add(new KeyValuePair<string, string>("key", key));
try
{
using (var client = new HttpClient())
{
var request = new HttpRequestMessage(HttpMethod.Post, "apiurl/api/something") { Content = new FormUrlEncodedContent(body) };
var result = await client.SendAsync(request);
if (!result.IsSuccessStatusCode)
{
return "false";
}
//string representation
var stringResponseFromServer = await result.Content.ReadAsStringAsync();
//convert JSON to series of objects
//LocationCollection locationCollection = JsonConvert.DeserializeObject<LocationCollection>(stringResponseFromServer);
//System.Diagnostics.Debug.WriteLine(locationCollection.locations.Count);
var response = JsonConvert
.DeserializeObject<GetLocationDataResponse>(stringResponseFromServer);
if (response == null) return "false";
jsonString.HttpGetLocationDataString += stringResponseFromServer;
return stringResponseFromServer;
}
}
catch
{
return "false";
}
}
My locations.cs looks like this
public class Locations
{
public int id { get; set; }
public string name { get; set; }
public string contact_first_name { get; set; }
public string contact_last_name { get; set; }
public string contact_email { get; set; }
public string contact_phone_number { get; set; }
public string billing_address { get; set; }
public string billing_city { get; set; }
public string billing_state { get; set; }
public string billing_zip { get; set; }
public string traps { get; set; }
}
Then I have a LocationCollection.cs where i hope to store the different locations so I can loop through them later and do whatever I need to do to them.
public class LocationCollection
{
public List<Locations> locations { get; set; }
}
And then I call the method on my MainPage after the user logs in
insectService.GetLocationData().ContinueWith(async (task) =>
{
var getLocationDataResponse = JsonConvert.DeserializeObject<GetLocationDataResponse>(task.Result);
if (getLocationDataResponse.status == "failure")
{
await DisplayAlert("Location Data Failure", "Could not retrieve data", "Try Again");
await Navigation.PushModalAsync(new LoginPage(), true);
}
//System.Diagnostics.Debug.WriteLine(getLocationDataResponse.locations.ToString());
if (getLocationDataResponse.status == "success")
{
await DisplayAlert("Location Data Success", "Successfully Recovered Data", "Back to Main Page");
}
}); //TaskScheduler.FromCurrentSynchronizationContext());
Right now I am able to get the expect JSON string of {\"status\":\"success\",\"locations\":[{\"id\":\"24\",\"name\":\"Test New Location Test\",\"contact_first_name\":\"Test\",\"contact_last_name\":\"Test\",\"contact_email\":\"test#email.com\",\"contact_phone_number\":\"(555) 555-5555\",\"billing_address\":\"Test\",\"billing_city\":\"Test\",\"billing_state\":\"AK\",\"billing_zip\":\"55555\",\"traps\":[]}]} and am able to check if the status is success or failure. However I am having trouble storing the different parts of "locations" into a list. Any suggestions?
You can give a try deserilizing your api result in to a result model, then from there again de serialize to location model. Example:
My API Model
public class ApiResult
{
public Int32 Status { get; set; }
public string Message { get; set; }
public string Data { get; set; }
}
Inside Data I copy all my return result from API, then Deserialize to exact Model. Here is the example:
public static List<Models.OrderList> RetrieveOrderList(string host, List<Models.FilterCondition> filter)
{
string sResult = HttpHelper.httpPost(host + "api/Order/RetrieveOrderList", Newtonsoft.Json.JsonConvert.SerializeObject(filter));
Models.ApiResult mResult = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.ApiResult>(sResult);
if (mResult.Status == 0)
throw new Exception(mResult.Message);
return Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.OrderList>>(mResult.Data);
}
If you see the above My return result(string), I deserialize to API result Model, then again finally deserialize to OrderList Model. Hope this help to sort out your issue.
Update: API Controller
I forgot to mention one more point. On the API Controller Side Your result need to copied to API Model.
Here is the Example
[HttpPost]
public Models.ApiResult RetrieveOrderList(List<Models.FilterCondition> conditions)
{
Models.ApiResult mResult = new Models.ApiResult();
try
{
List<Models.OrderList>mOrderList= BLL.Order.RetrieveOrderList(conditions);
mResult.Status = 1;
mResult.Message = "Success";
mResult.Data = Newtonsoft.Json.JsonConvert.SerializeObject(mOrderList);
return mResult;
}
catch (Exception ex)
{
mResult.Status = 0;
mResult.Message = ex.Message;
mResult.Data = "";
return mResult;
}
}
My locations model didn't match the JSON response. Once I read what the exception was in my catch statement I saw that 'traps' was supposed to be another list. After I changed traps property to a List and then made another class for 'traps' everything worked fine.
I am creating a Web Api method that should accept a JSON Object and a Simple Type. But all parameters are always null.
My json looks like
{
"oldCredentials" : {
"UserName" : "user",
"PasswordHash" : "myCHqkiIAnybMPLzz3pg+GLQ8kM=",
"Nonce" : "/SeVX599/KjPX/J+JvX3/xE/44g=",
"Language" : null,
"SaveCredentials" : false
},
"newPassword" : "asdf"}
And my Code looks like:
[HttpPut("UpdatePassword")]
[Route("WebServices/UsersService.svc/rest/users/user")]
public void UpdatePassword([FromBody]LoginData oldCredentials, [FromBody]string newPassword)
{
NonceService.ValidateNonce(oldCredentials.Nonce);
var users = UserStore.Load();
var theUser = GetUser(oldCredentials.UserName, users);
if (!UserStore.AuthenticateUser(oldCredentials, theUser))
{
FailIncorrectPassword();
}
var iv = Encoder.GetRandomNumber(16);
theUser.EncryptedPassword = Encoder.Encrypt(newPassword, iv);
theUser.InitializationVektor = iv;
UserStore.Save(users);
}
The current JSON you are sending maps to the following classes
public class LoginData {
public string UserName { get; set; }
public string PasswordHash { get; set; }
public string Nonce { get; set; }
public string Language { get; set; }
public bool SaveCredentials { get; set; }
}
public class UpdateModel {
public LoginData oldCredentials { get; set; }
public string newPassword { get; set; }
}
[FromBody] can only be used once in action parameters
[HttpPut("WebServices/UsersService.svc/rest/users/user")]
public void UpdatePassword([FromBody]UpdateModel model) {
LoginData oldCredentials = model.oldCredentials;
string newPassword = model.newPassword;
NonceService.ValidateNonce(oldCredentials.Nonce);
var users = UserStore.Load();
var theUser = GetUser(oldCredentials.UserName, users);
if (!UserStore.AuthenticateUser(oldCredentials, theUser)) {
FailIncorrectPassword();
}
var iv = Encoder.GetRandomNumber(16);
theUser.EncryptedPassword = Encoder.Encrypt(newPassword, iv);
theUser.InitializationVektor = iv;
UserStore.Save(users);
}
As per the Parameter Binding in ASP.NET Web API, "At most one parameter is allowed to read from the message body". Means only one parameter can contain [FromBody]. So in this case it will not work. Create one complex object and add required properties to it. You can add newPassword to your complex object to make it work.
More than one [FromBody] does not work in Api. Check this Microsoft Official blog
So now you can do like this, create a complex object which should contain both your oldCredentials and newPassword. For example LoginData class in my example bellow. And myLoginRequest is another object class which is to deserialized your LoginData.
[HttpPut("UpdatePassword")]
[Route("WebServices/UsersService.svc/rest/users/user")]
public void UpdatePassword([FromBody]LoginData MyCredentials)
{
loginRequest request = JsonConvert.DeserializeObject<myLoginRequest>
(json.ToString());
// then you can do the rest
public class DocumentController : ApiController
{
[HttpPost]
public IHttpActionResult PostDocument([FromBody] Container data)
{
try
{
if (string.IsNullOrWhiteSpace(data.Document)) return ResponseMessage(Request.CreateResponse(HttpStatusCode.NoContent, "No document attached"));
return ResponseMessage(IndexDocument(data, Request));
}
catch (Exception ex)
{
return ResponseMessage(Request.CreateResponse(HttpStatusCode.NotAcceptable, ex.Message));
}
}
}
public class InsuranceContainer
{
[JsonProperty("token")]
public string Token { get; set; }
[JsonProperty("document")]
public string Document { get; set; }
[JsonProperty("text")]
public string Text { get; set; }
}
var fileAsBytes = File.ReadAllBytes(#"C:\temp\tmp62.pdf");
String asBase64String = Convert.ToBase64String(fileAsBytes);
var newModel = new InsuranceContainer
{
Document = asBase64String,
Text = "Test document",
};
string json = JsonConvert.SerializeObject(newModel);
using (var stringContent = new StringContent(json, System.Text.Encoding.UTF8, "application/json"))
using (var client = new HttpClient())
{
var response = await client.PostAsync("https://www.mysite.dk/WebService/api/Document/PostDocument", stringContent);
Console.WriteLine(response.StatusCode);
var message = response.Content.ReadAsStringAsync();
Console.WriteLine(message.Result);
}
public class Response
{
public User[] Users { get; set; }
}
public class User
{
public string Uid { get; set; }
public string First_Name { get; set; }
public string Last_Name { get; set; }
public int Online { get; set; }
public int[] Lists { get; set; }
}
private void c_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
lock (this)
{
string json = e.Result;
// var response = JsonConvert.DeserializeObject(json);
var response = JObject.Parse(json);
// var COUNT = JsonConvert.DeserializeObject<List<User>>(json);
// MessageBox.Show(response.ToString());
var getcount = response["response"].Children<JObject>();
int count_friends=getcount.Cast<JToken>().Values("uid").Count();
Response rr = new Response();
for (int i = 0; i <count_friends; i++) {
//rr.Users.ToDictionary(rr.Users[i].Uid => response["response"][i]["uid"].ToString());
// rr.Users[i].First_Name = response["response"][i]["first_name"].ToString(); --DOESN'T WORKS
// Debug.WriteLine("OUT: "+(string)response["response"][i]["uid"].ToString());
//Debug.WriteLine("OUT: " + COUNT.Count());
}
Debug.WriteLine(rr.Users.ToString());
// string[] names = rr.Users.Select(d => d.First_Name).ToArray();
// string[] uids = response.Users.Select(d => d.Uid).ToArray();
// Dictionary<string,string> users = response.Users.ToDictionary(d => d.First_Name);
// Dictionary<string, string> usersById = response.Users.ToDictionary(d => d.Uid, d => d.First_Name);
}
}
I need to get acces to a dictionary like "select from Response.User all where Online==1"
But in the start how I can create a DB(linq) with classes above ?
All values stored in response["response"][i]["uid"],response["response"][i]["first_name"]...
is this what your looking for?
Dictionary<string,List<Dictionary<string,object>>>
this is vary bad design, try and rethink the problem to come up with a better solution
public struct User {
public int Uid;
public string First_Name;
public string Last_Name;
public bool isonline;
}
Than you can write values like
User[] usr= new User[count_friends];
// Response rr = new Response();
for (int i = 0; i <count_friends; i++) {
usr[i].Uid =(int) response["response"][i]["uid"];