Hi to all
I Need to clone row using linq. i found this method:
public static T Clone<T>(this T source)
{
var dcs = new System.Runtime.Serialization
.DataContractSerializer(typeof(T));
using (var ms = new System.IO.MemoryStream())
{
dcs.WriteObject(ms, source);
ms.Seek(0, System.IO.SeekOrigin.Begin);
return (T)dcs.ReadObject(ms);
}
}
but when try to clone row, like db1.Persons.First().Clone();
i get this exception: "Object graph for type 'TestLinq.PersonAddress' contains cycles and cannot be serialized if reference tracking is disabled."
Note: My Table contains 1 primary key and 1 unique index include 3 field
Could you please help me
Thanks
Hamid