I'm probably not asking the correct question.
static void GetEveryThing<t>(string Token)
{
t x = JsonConvert.DeserializeObject<t>(GetData("Original API Query", Token));
string NextLink = x.nextLink;
while (NextLink != null)
{
t z = JsonConvert.DeserializeObject<t>(GetData(NextLink, Token));
x.value.AddRange(z.value);
NextLink = z.nextLink;
}
}
I have seven different classes that need to use the above code. All the classes have properties 'count', 'value', and 'nextLink'. Value is a List<T>
that holds the actual returned data. nextLink is returned from the API query and just has the next Query Link to keep getting information.
The error is, I can't get x.nextLink, z.count, z.nextLink, x.value, z.value, or z.nextLink. Error Code CS1061. I don't know how to use the <t>
to make this work.
I can add the classes in question, GetData, or anything else that may help. I feel that this is something fundamental and I just don't know how to do it or ask the correct question.
How do I make this work?
Edit:
Here are two classes I'm trying to use;
class OfficeData
{
[JsonProperty("@odata.context")]
public string context { get; set; }
public List<OfficeAssocDataRows> value { get; set; }
[JsonProperty("@odata.count")]
public int count { get; set; }
[JsonProperty("@odata.nextLink")]
public string nextLink { get; set; }
}
class MembersData
{
[JsonProperty("@odata.context")]
public string context { get; set; }
public List<MemberAssocDataRows> value { get; set; }
[JsonProperty("@odata.count")]
public int count { get; set; }
[JsonProperty("@odata.nextLink")]
public string nextLink { get; set; }
}
--- This question has been closed, so leaving here as a note.
Second Edit:
I've almost got the interface setup;
interface IAPIDataInterface
{
[JsonProperty("@odata.context")]
public string context { get; set; }
//public List<T> value { get; set; } <-- How do I get this to pass through?
[JsonProperty("@odata.count")]
public int count { get; set; }
[JsonProperty("@odata.nextLink")]
public string nextLink { get; set; }
}
class OfficeData : IAPIDataInterface
{
[JsonProperty("@odata.context")]
public string context { get; set; }
public List<OfficeAssocDataRows> value { get; set; }
[JsonProperty("@odata.count")]
public int count { get; set; }
[JsonProperty("@odata.nextLink")]
public string nextLink { get; set; }
}
class MembersData : IAPIDataInterface
{
[JsonProperty("@odata.context")]
public string context { get; set; }
public List<MemberAssocDataRows> value { get; set; }
[JsonProperty("@odata.count")]
public int count { get; set; }
[JsonProperty("@odata.nextLink")]
public string nextLink { get; set; }
}