I am trying to make a deep copy of an L2S unit using the code below. I have the DDRML serialization mode Which is in unidirectional. However, when I try to make a deep copy of the L2S unit, using the DeepCP method below, I get an error saying that the object is not marked as serializable. Anyone know why?
Public Static Tea Lamp & lt; T & gt; (T OBJ) {Object result = zero; (Var ms = new memorystream ()) using {var formatter = New BinaryFormatter (); Formatter.Serialize (MS, obj); Ms.osition = 0; Result = (t) formatter.Deserialize (MS); Ms.Close (); } Return (t) result; } One of my L2S class definitions is as follows:
[global :: System.Data.Linq.Mapping.TableAttribute (name = "Polar .Recipe")] [Global :: System.Runtime.Serialization.DataContractAttribute ()] Public Partial Class RecipeRecord: INotifyPropertyChanging, INotifyPropertyChanged After text work with other serializers like "itemprop =" text "> DataContract attribute DataContractSerializer but wont ' BinarySerializer , ViewStateSerializer and others Is required for serializers For them to work, you have to use the serializable attribute to apply them. Now how can it be easier ... When I want to extend my Linux 2 SQL units, I usually misuse the fact that they are all partial classes. Therefore, I create the file Linq2SqlExtensions.cs
public partial class LinqEntity {// extensions go here} and other extensions (eg example data for reference extensions ). Now if you have several organizations you can update it for a small program (even in powershell) to extract all the name of your Linq2Sql namespace / assembly out of the name of the class (I pray you have them one And is in the assembly) and you can create this file for yourself and automatically run you from every VisualStudio command line (or MSBuild script).
like entities = assembly.Load ("MyLinqAssembly"). GetTypes () Where (P => P. ISDefine (typef (tablettetbet), true)); WriteEntityCsFile (entities);
Comments
Post a Comment