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
|
hi - i'm using the Mindscape.LightSpeed.Generator.Integration.Dsl to gen dtos. i'm trying to work with a user defined type - but calling property.DataType.GetClrType() just returns object for all udts. eg public <#= property.DataType #><# if (property.IsNullable && property.DataType.GetClrType().IsValueType) { #>?<# } #> <#= property.Name #> { get; set; } problem is that all my enum udts are returning object for property.DataType.GetClrType() which of course is never a value type - and so they never pick up when they should be nullable. I'm guessing there should be an override (which currently there is not) of GetClrType() in the type Mindscape.LightSpeed.Generator.Model.NamedTypeModelDataType, similar to that in Mindscape.LightSpeed.Generator.Model.StandardTypeModelDataType. Is that correct? thanks |
|
|
This occurs because a ModelDataType doesn't actually know what CLR type it's going to get turned into: that decision occurs at the Model level where the UDTs are defined. (There are a number of reasons for this, some good ones, some, er, not so good ones.) So what you need to do is query the property's containing Model and ask it to resolve the type for you: property.Model.GetClrType(property.DataType) This returns a ClrCustomDataType object (NOT a Type object, because the Type may not exist at code gen time!), from which you can get the TypeName to emit into your code. |
|
|
ah, of course. thanks. |
|