2
I am creating a Task List<> but the same shows error in 'Tmodel' Error shown: "Tmodel" type or namespace name cannot be found (using a directive or Assembly reference?)
public async Task<List<TModel>>MetodoPostTeste(string RouteCommand, params object[] args)
{
var ModelType = typeof(TModel);//take the class
var ModelTypeName = ModelType.Name;//take the class name
var ModelWorldLength = "_lib".Length;//takes the size of the class name up to _lib
//subtracts from the name of the class the _lib, thus being able to specify the route for the post
var ModelTypeNameRoute = $"{ModelTypeName.Substring(0, ModelTypeName.Length - ModelWorldLength)}";
_client.BaseAddress = new Uri(_commom.GetBaseUrl());
var request = new HttpRequestMessage(HttpMethod.Post, $"api/{ModelTypeNameRoute}/{RouteCommand}");
request.Content = new StringContent(JsonConvert.SerializeObject(""), Encoding.UTF8, "application/json");
var response = await _client.SendAsync(request);
var x = response.Content.ReadAsStringAsync();
List<TModel> ret = JsonConvert.DeserializeObject<List<TModel>>(x.Result);
return ret;
}
yes, Generic type T is Tmodel
– Vinicius Dantas
When I hover over List<Tmodel> it informs T is Tmodel
– Vinicius Dantas
That’s right, I could use it here
– Vinicius Dantas