Using the following code:
Private Sub MakeMeSomeXmlBeforeRyanGetsAngry()
Dim db As New MyDBDataContext
Dim customer = From c In db.Customers Select c
Dim dcs As New DataContractSerializer(GetType(Customer))
Dim sb As StringBuilder = New StringBuilder
Dim writer As XmlWriter = XmlWriter.Create(sb)
dcs.WriteObject(writer, customer)
Dim xml As String = sb.ToString
Response.Write(xml)
End Sub
I am trying to serialize my collection of linq clients. But he keeps throwing
The type 'System.Data.Linq.DataQuery`1 [MyDB.Customer]' cannot be serialized. Consider labeling it with the DataContractAttribute attribute and labeling all of its elements that you want to serialize with the DataMemberAttribute attribute. See the Microsoft.NET Framework documentation for other supported types.
My problem is that I already marked the Serialization dbml mode for UniDirectional, and when I check the dbml code, all the DataContract ()> and DataMember ()> elements are there.
I am not sure how to proceed. I tried to add various dataloadoptions and set the delayed load to false, but no luck.
Ideas?