-
Notifications
You must be signed in to change notification settings - Fork 127
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
Enhancement: Support for returning IDictionary<string, object> instead of ExpandoObject. #537
Comments
As background, in F# you can implement the let (?) (x:obj) (key) = (x :?> IDictionary<string, obj>).[key]
let data = conn.ExecuteQuery "SELECT Col1, Col2 FROM Table" // data is type IEnumerable<obj>
let stuff = data |> Seq.map(fun row -> row?Col1) // Note the use of "?" here. |
Just to clarify, the resultset of this is of type |
Yes. When you say "all the mentioned columns types" I assume you mean the values in each row (not the column names!)? And yes, that's what the Expando Object is underneath the hood. It just wraps it in a special interface that C# knows about to give it the dynamic capabilities. |
Yes, the name = |
Right. I'm not sure what else it could really be? This is what the Expando is behind the scenes. The only other option is potentially to expose the "raw" ADO .NET DB type out so that you can safely ask it what type it is before casting from object to e.g. string etc. |
Cool! I will try to see if I can get the data type back as I already have the proper resolver for that. The only reason I ask is because ExpandoObject is only limited to IDictionary<string, object>. |
I think realistically it would probably need to be a <string, obj> collection because each row may have different types in across the columns. |
Atleast I can create a thing like this public class RowValue
{
public Type DataType { get; set; }
public object Value { get; set; } /* This is always object */
} But I am also afraid to dictate to the user to bind their code to that |
…ionary<string, object> resultsets.
The fix is available at version RepoDb v1.12.0-beta3 or above. |
@isaacabraham - we are closing this ticket now. Please do let us know if you still have questions. Thanks |
F# doesn't have "out of the box" support for dynamic typing (although it's something that you could add support for). Instead, it would be nice to be able to request an
IDictionary<String,Object>>
from a query e.g.You can work around this with a one liner, but not everyone (and especially developers with no C# experience) will know how to do this:
The text was updated successfully, but these errors were encountered: