Code Monkey home page Code Monkey logo

Comments (2)

sivak4Net avatar sivak4Net commented on June 25, 2024

I am using AspNetCore.OData 8.2.5 and .net6 Api
Have a dbcontext entity as Product, On top of Product i have a json converter which is not working as expected like
From Product entity response i want to concate the properties

`[JsonConverter(typeof(ProductDataConverter))]
public class Product
{
public int Id { get; set; }
public string Name { get; set; }

public List<DataRow> Data { get; set; }
public string Schema { get; set; }

}

public class DataRow
{
public int Id { get; set; }
public int ProductId { get; set; }
public string Data { get; set; }
}`

my api will be
`public async Task Get(string dataSourceName, ODataQueryOptions options)
{

//var dataSource = await _productDataService.GetDataProductByQuery(dataSourceName).FirstAsync();
var dataSource = await ApplyODataQuery(dataSourceName, options).FirstOrDefaultAsync();         



return Ok(dataSource);

}

private IQueryable ApplyODataQuery(string dataSourceName, ODataQueryOptions options)
{
IQueryable dataSource = _productDataService.GetDataSourceByQuery(dataSourceName).IgnoreAutoIncludes();
var result = options.ApplyTo(dataSource);
return result.Cast();
}`

When i execute this code then i am getting the below exception
"Error": {
"Code": 500,
"Message": "Token PropertyName in state Property would result in an invalid JSON object. Path 'Container.Value[0].Instance'."
}

Any help would be appreciate, i tried many ways but nothing is working out, Once we execute the db query if i see the result it showing as AspNetCore.SelectAllExpand with out converter i am able to get the data as expected but if i register that converter then it's not working

from aspnetcoreodata.

julealgon avatar julealgon commented on June 25, 2024

On top of Product i have a json converter which is not working as expected like
From Product entity response i want to concate the properties

Can you elaborate a bit more on this? What does your converter to, and why do you need a converter in the first place?

from aspnetcoreodata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.