@@ -26,8 +26,7 @@ Namespace Design.Internal
26
26
_typeMappingSource = typeMappingSource
27
27
End Sub
28
28
29
- Private Shared ReadOnly _literalFuncs As IReadOnlyDictionary( Of Type, Func( Of VisualBasicHelper, Object , String )) =
30
- New Dictionary( Of Type, Func( Of VisualBasicHelper, Object , String )) From
29
+ Private Shared ReadOnly _literalFuncs As New Dictionary( Of Type, Func( Of VisualBasicHelper, Object , String )) From
31
30
{
32
31
{ GetType ( Boolean ), Function (c, v) c.Literal( CBool (v))},
33
32
{ GetType ( Byte ), Function (c, v) c.Literal( CByte (v))},
@@ -578,6 +577,60 @@ Namespace Design.Internal
578
577
Return builder.ToString()
579
578
End Function
580
579
580
+ ''' <summary>
581
+ ''' This API supports the Entity Framework Core infrastructure And Is Not intended to be used
582
+ ''' directly from your code. This API may change Or be removed in future releases.
583
+ ''' </summary>
584
+ Public Overridable Function Literal( Of T)(values As List( Of T), Optional vertical As Boolean = False ) As String
585
+ Return ListLitetal( GetType (T), values, vertical)
586
+ End Function
587
+
588
+ Private Function ListLitetal(type As Type, values As IEnumerable, Optional vertical As Boolean = False ) As String
589
+
590
+ Dim builder As New IndentedStringBuilder()
591
+
592
+ builder.
593
+ Append( "New List(Of " ).
594
+ Append(Reference(type)).
595
+ Append( ")" )
596
+
597
+ Dim hasData = False
598
+ Dim first = True
599
+
600
+ For Each value In values
601
+ hasData = True
602
+ If first Then
603
+ builder.Append( " From {" )
604
+ If vertical Then
605
+ builder.AppendLine()
606
+ builder.IncrementIndent()
607
+ End If
608
+ first = False
609
+ Else
610
+ builder.Append( ","c )
611
+
612
+ If vertical Then
613
+ builder.AppendLine()
614
+ Else
615
+ builder.Append( " "c )
616
+ End If
617
+ End If
618
+
619
+ builder.Append(UnknownLiteral(value))
620
+ Next
621
+
622
+ If hasData Then
623
+ If vertical Then
624
+ builder.AppendLine()
625
+ builder.DecrementIndent()
626
+ End If
627
+
628
+ builder.Append( "}"c )
629
+ End If
630
+
631
+ Return builder.ToString()
632
+ End Function
633
+
581
634
''' <summary>
582
635
''' This API supports the Entity Framework Core infrastructure And Is Not intended to be used
583
636
''' directly from your code. This API may change Or be removed in future releases.
@@ -682,6 +735,13 @@ Namespace Design.Internal
682
735
Return ArrayLitetal(LiteralType.GetElementType(), DirectCast (value, Array))
683
736
End If
684
737
738
+ If TypeOf value Is IList AndAlso
739
+ value.GetType().IsGenericType AndAlso
740
+ value.GetType().GetGenericTypeDefinition() Is GetType (List( Of )) Then
741
+
742
+ Return ListLitetal(value.GetType().GetGenericArguments()( 0 ), DirectCast (value, IList))
743
+ End If
744
+
685
745
Dim mapping = _typeMappingSource.FindMapping(LiteralType)
686
746
If mapping IsNot Nothing Then
687
747
Dim builder As New StringBuilder
0 commit comments