Hi,
I am trying to run the following code. But the code breaks
Dim complaints = From comp In Me.Db.Complaints _
Let varX = GetVariations().WithVariationId(If(comp.ItemPropertyXVariationId, 0)) _
Let varY = GetVariations().WithVariationId(If(comp.ItemPropertyYVariationId, 0)) _
Select New Hogia.Retail.POS.Data.Complaint() With _
{.ItemXVariation = If(varX Is Nothing, DirectCast(String.Empty, String), varX.Name)}
.ItemXVariation is a property of string type. Now i tested this line of code outside the LINQ statement in the following manner and it worked fine, returned the proper result as i expected
Dim varXX = GetVariations().WithVariationId(0)
Dim varYY = GetVariations().WithVariationId(0)
Dim temp As New Complaint() With {.ItemXVariation = If(varXX Is Nothing, DirectCast(String.Empty, String), varXX.Name)}
Could someone please help me understand why the code in the first block breaks. what is wrong in there.
Here is the message that comes up (help me make sense out of this)
Could not translate expression 'Table(Complaint).Select(comp => new VB$AnonymousType_22
(comp = comp, varX = Invoke(value(System.Func
1[System.Linq.IQueryable1[
Data.ItemPropertyVariation]])).WithVariationId((comp.ItemPropertyXVariationId ?? 0)))).Select($VB$It1 => new VB$AnonymousType_3
2($VB$It1 = $VB$It1, varY = Invoke(value(System.Func1[System.Linq.IQueryable
1[Data.ItemPropertyVariation]])).WithVariationId(($VB$It1.comp.ItemPropertyYVariationId ?? 0)))).
Select($VB$It => new Complaint() {ItemXVariation =
IIF((Convert($VB$It.$VB$It1.varX) = null), null, $VB$It.$VB$It1.varX.Name)})'
into SQL and could not treat it as a local expression.