Skip to content
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

Implement casting to fully qualified type #652

Closed
StefH opened this issue Nov 26, 2022 · 4 comments
Closed

Implement casting to fully qualified type #652

StefH opened this issue Nov 26, 2022 · 4 comments
Assignees
Labels

Comments

@StefH
Copy link
Collaborator

StefH commented Nov 26, 2022

namespace X
{
    internal class Program
    {
        [DynamicLinqType]
        public enum ExampleEnum
        {
            Value1,
            Value2,
        };

        private static readonly ParsingConfig DefaultParsingConfig = new() { 
        };

        static void Main(string[] args)
        {
            var data = new[]
            {
                new { Value = ExampleEnum.Value1 },
                new { Value = ExampleEnum.Value2 },
            };

            // This should work:
            data.AsQueryable().Select(DefaultParsingConfig, $"\"{typeof(ExampleEnum).FullName}\"?(Value)");  

        }
    }
}

Related: #643

@StefH StefH self-assigned this Nov 26, 2022
@StefH
Copy link
Collaborator Author

StefH commented Nov 27, 2022

@jbhelm

I've update the code to support casting to a FullName type using " -->

"\"System.DateTime\"(Value)"
or
"\"My.NameSpace.EnumX\"(Value)"

Nullable does also work:

"\"System.DateTime\"?(Value)"
or
"\"My.NameSpace.EnumX\"?(Value)"

Can you please test preview:
1.2.24-preview-02

@StefH StefH added the feature label Nov 27, 2022
@jbhelm
Copy link

jbhelm commented Nov 27, 2022

@StefH
I've tried the preview in my scenario. I can confirm this works for me using fully qualified names, without the DynamicLinqType attribute on the types. Thank you!

@StefH
Copy link
Collaborator Author

StefH commented Nov 28, 2022

Thanks for testing.

@StefH
Copy link
Collaborator Author

StefH commented Nov 29, 2022

Done

@StefH StefH closed this as completed Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants