Is it possible with Dapper to read a non default type that is implemented by the NpgsqlDataReader?
Npgsql implements multiple types for some postgresql types: https://www.npgsql.org/doc/types/basic.html
The default type is returned when using NpgsqlCommand.ExecuteScalar(), NpgsqlDataReader.GetValue() and similar methods.
You can read as other types by calling NpgsqlDataReader.GetFieldValue<T>().
Is there any way to force Dapper to call GetFieldValue<T> internally?
I tried registering a SqlMapper but when I register it for a non default type still the default type is passed into the Parse(object) method
It is not possible at the moment: https://github.com/StackExchange/Dapper/issues/1644
Related
In OWL API, there method getObjectPropertiesInSignature() can be used to obtain the set of object properties in an ontology. I have two questions with respect to this:
By using this method, will it return also the object properties in imported ontology ?
Also, this method is deprecated in the latest version of OWL API, is there another method with the same behaviour ?
getObjectPropertiesInSignature() has an overloaded version with a boolean flag, its purpose is to allow you to choose to look in the signature of the ontology or in the signature of the imports closure. Use it to get the object properties for the whole imports closure.
The method is deprecated and the javadoc suggests using the stream based method. For all such scenarios in OWLAPI 5, methods named getXxx() have an alternative version named xxx() that returns a stream. It is preferable to use them if you need only one iteration through the underlying collection (it saves having to make defensive copies). If you need multiple iterations or lookups, you can keep using the deprecated methods or collect the data from the stream in a set.
We're updating code to use Autofac. We'd like to use custom delegate types to define factories instead of Func's. But we also use an obfuscator, which renames parameters. We'd like to tell the Autofac container to match by type instead of name as it does with Func's. Is this possible?
On the official documentation of Autofac, you have this information
By default, Autofac matches the parameters of the delegate to the parameters of the constructor by name. If you use the generic Func types, Autofac will switch to matching parameters by type.
http://docs.autofac.org/en/latest/advanced/delegate-factories.html
Could you customize the obfuscator to use the same name for the parameter name of the delegate and the constructor?
As mentioned, the way to do it right now is to use Func. Even if it were possible with just delegate factories, Autofac won't know what to do when there are two parameters of the same type. Here's my answer to a very similar question.
Thanks guys. We ended up creating a custom registration source using Autofac's source as a guide. In our testing, if there are two parameters of the same type, it appears to fall back to order.
I've been trying to find some info on difference between instantiating form fields through static method and the new keyword. Can somebody tell me what are the practical implications, limitations, between new MyFormField and MyFormField::create() esp. with regards to SilverStripe
Using the create factory method would check for overloads (set via Object::useCustomClass()) and return an instance of the custom class in that case.
This method first for strong class overloads (singletons & DB
interaction), then custom class overloads. If an overload is found, an
instance of this is returned rather than the original class. To
overload a class, use Object::useCustomClass()
So using the create method rather than instantiating the Object yourself would provide a possibility to overload the used Class without altering the code.
see
http://api.silverstripe.org/3.1/class-Object.html#_useCustomClass
http://api.silverstripe.org/3.1/class-Object.html#_create
I want to Pass 'Map' to an PL/SQL Stored Procedure via Spring Mybatis Mapper XML.
Is there any way i can pass it via using appropriate java type and jdbctype.I can use a Java class to map to appropriate TypeHandler, but is there any other way we can do this without using a type handler.
You have to use a TypeHandler. That's how MyBatis sets Java types set into Prepared and Callable Statements.
If you register the TypeHandler with your MyBatis configuration, then MyBatis will choose the correct type handler automatically, avoiding typing "typeHandler=..." in the sql map. That's how you can get it to use javaType variable to find your type handler.
i.e. (org.apache.ibatis.session.Configuration)
configuration.getTypeHandlerRegistry().register(HashMap.class, new MyPLSQLTypeHandler());
I'm using HtmlPage.RegisterCreateableType method to call some C# code from javascript. In MSDN documentation they say:
Registers a managed type as available for creation from JavaScript
code, through the Content.services.createObject and
Content.services.createManagedObject helper methods
There isn't more explanation about these two methods and I don't know what are the differences. Anybody knows differences between these methods?
Tons of information on both of these methods here.
createObject
Description: Given a registered scriptAlias, this method returns a
script wrapper for the corresponding managed type.
createManagedObject
Description: Given the typeName of the target .NET Framework type,
this method creates a default instance of the type by using either a
parameterless constructor (for reference types) or the default value
representation (for value types).
Basically, you use createObject if you have a script alias to an object. If you just need to create an instance of a type of object you use createManagedObject.