This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
One of my tables uses that sql_variant datatype for a column. LS seems to map it as a .Net Object type, however, when I retrieve the values of this table, the value for this field is always null. So my question is, is sql_variant a supported type? I checked the documentation and the forum, but the only mention was very old, and seemed to indicate that it is not support.
|
|
|
We don't currently test with sql_variant so I guess it is not supported. However if you know the data type that is going to be in the column then you might be able to map it manually. For example if you know that the column is always going to contain integer values then edit the property to be an Int32 or Int64 instead of Object. I can't guarantee that this will work but it's worth a try. If the column does contain different kinds of data then I'll need to investigate and see if this is something we can support -- let me know, and any additional info you can provide about the data and desired behaviour would be useful. Not making any promises though! |
|
|
Hi Ivan, Within this field we store int's, strings, and nulls, so editing the property to be a string or Int32 would not work. Previously, when using the SQLClient directly to retrieve the information, we retrieve it as an Object, the controls we pass the value to then work out themselves how the value should be cast and used. Ideally, I would like LS to return the value as an Object also. Thanks.
|
|
|
This works for me if I add the ValueFieldAttribute to the field, as follows: public class VariantTestItem : Entity<int> I don't think the designer supports ValueFieldAttribute so you will need to implement this in the partial class (set Generation = None and write the code by hand, or you can use Refactor > Convert to Manual Implementation as a shortcut to get started). I have added this to the test suite so you can have confidence that this will be formally supported going forward. |
|
|
Update: I think you can make this work in the designer by creating a User Defined Type with the following settings: CLR Type Name: System.Object Then edit your properties to be the custom SqlVariant type instead of plain old Object. (Use the LightSpeed Model Explorer -- View > Other Windows > LightSpeed Model -- to declare UDTs.) |
|
|
Hi Ivan, Worked great, thanks for your help.
|
|