I need to clone a string 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 trying to clone a string, for example, db1.Persons.First (). Clone ();
I get this exception: "The object graph for type" TestLinq.PersonAddress "contains loops and cannot be serialized if link tracking is disabled."
Note. My table contains 1 primary key and 1 unique index includes 3 fields
Could you help me
Thanks
Hamida
c # serialization linq-to-sql
Hamid
source share