New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function support for string return type or string arguments #258

Closed
marianc opened this Issue Nov 17, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@marianc

marianc commented Nov 17, 2015

Hi,

I am trying to use an unbound function which returns a string or which takes string as arguments but in both cases I get an error: 'Not supported type: System.Char.'

Please find below the code to illustrate the problem:

public class DataSourceController : ODataController
{
    ...

    [ODataRoute("GetPersonAge(name={name})")]
    public IHttpActionResult GetPersonAge(string name)
    {
        return Ok(Api.GetPersonAge(name));
    }

    [ODataRoute("GetSamplePerson(n={n})")]
    public IHttpActionResult GetSamplePerson(int n)
    {
        return Ok(Api.GetSamplePerson(n));
    }

    ...

}


public class DataSourceApi : DbApi<DataSourceContext>
{

    [Function]
    public int GetPersonAge(string name)
    {
        return 35;
    }

    [Function]
    public string GetSamplePerson(int n)
    {
        return "Person Name";
    }

}

Thank you for your help.

@lewischeng-ms lewischeng-ms self-assigned this Nov 17, 2015

@lewischeng-ms lewischeng-ms added this to the 0.4.0 milestone Nov 17, 2015

@lewischeng-ms

This comment has been minimized.

Contributor

lewischeng-ms commented Nov 17, 2015

@marianc Thank you very much for reporting this issue. This is a bug in a helper method which is to get the element type from a given type. Since string implements IEnumerable<char>, the method mistakenly thinks the element type is Char and returns it. I will fix this issue soon.

@lewischeng-ms

This comment has been minimized.

Contributor

lewischeng-ms commented Nov 18, 2015

Fixed in 3f659ea

@marianc

This comment has been minimized.

marianc commented Nov 18, 2015

Thank you for the very quick response and solution.
It took me some time to check it into my application but it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment