This question is locked. New answers and comments are not allowed.
Hi,
I create my schema object, and I create my database (OK).
First, I add in each object class the "option" ==> [Serializable].
Secand, when I modify my entity schéma.....This "option" is loose for all object class....
and I am obliged to re-apply option [Serializable] on each object class....
Please, do you have a solution to apply option [Serializable] and that the system memorize it !!!
In advance,
Thanks,
Richard.
I create my schema object, and I create my database (OK).
First, I add in each object class the "option" ==> [Serializable].
Secand, when I modify my entity schéma.....This "option" is loose for all object class....
and I am obliged to re-apply option [Serializable] on each object class....
Please, do you have a solution to apply option [Serializable] and that the system memorize it !!!
In advance,
Thanks,
Richard.
5 Answers, 1 is accepted
0
Hello Marchand,
You will notice that the class we have generated is partial. This means that it can be extended by adding the a class with the same name and same modifiers in a different file like this:
This way you will always keep the changes on a class level since they are in a different file than the one we regenerate.
Petar
the Telerik team
This is actually the expected behavior. Since we use T4 templates to generate our classes, you are getting your model completely regenerated on each model change. In order to persist changes on a class level you will have to extend your generated classes with ones that are manually created by you. So for example if you have a class generated by us that is similar to this:
public
partial
class
Category
{
private
int
iD;
public
virtual
int
ID
{
get
{
return
this
.iD;
}
set
{
this
.iD = value;
}
}
}
[Serializable]
public
partial
class
MetaClass1
{
}
Petar
the Telerik team
0
Marchand
Top achievements
Rank 1
answered on 07 Feb 2011, 05:54 PM
Hi,
I don't understand your answer...
==> you said...
......
}
This is the classe generated by telerik ORM.
Them, I must created class, but the name a the partial class is "MetaClass1" ???
I don't understand your answer...
==> you said...
public
partial
class
Category
{
}
This is the classe generated by telerik ORM.
Them, I must created class, but the name a the partial class is "MetaClass1" ???
[Serializable]
public
partial
class
MetaClass1
{
}
Thanks,
0
Hi Marchand,
The name of the partial class should match the one we have generated.
Petar
the Telerik team
You are correct. I have copied the wrong class from my project. The actual partial class should look like this:
[Serializable]
public
partial
class
Category
{
}
Petar
the Telerik team
0
KubuliJohn
Top achievements
Rank 1
answered on 30 Jul 2012, 03:45 PM
Is this answer still true? I have dozens, soon to be hundreds of automatically generated entity classes - do I really have to create dozens soon to be hundreds of empty partial classes simply to apply the [Serializable] attribute? They all have to be serializable in order to use them as the datasource for a RadGrid.
[Update] - last statement is not true - I had just refactored all of my joining column names and had some datakeyname entries that were now being interpreted as the navigational entities instead of the foreign key field name. However, an easier way to define persistent serialization settings would still be nice...
[Update] - last statement is not true - I had just refactored all of my joining column names and had some datakeyname entries that were now being interpreted as the navigational entities instead of the foreign key field name. However, an easier way to define persistent serialization settings would still be nice...
0
Hello,
If the Serializable attribute should be applied to all classes in the model, it might be easier to modify the code generation templates, so that the attribute is generated automatically.
Here is how to modify the templates:
- Open the (OpenAccess install path)\dsl(VS version)\CodeGenerationTemplates\CSharp(or VisualBasic)\Includes\MainCs.ttinclude file in a text editor
- Edit the foreach loop on line 23 and add the following three lines:
- Save the template and from Visual Studio save the rlinq file in order to trigger the code generation.
This way the Serializable attribute is added to each class before it is generated. Hope that helps.
Greetings,
Alexander
the Telerik team
If the Serializable attribute should be applied to all classes in the model, it might be easier to modify the code generation templates, so that the attribute is generated automatically.
Here is how to modify the templates:
- Open the (OpenAccess install path)\dsl(VS version)\CodeGenerationTemplates\CSharp(or VisualBasic)\Includes\MainCs.ttinclude file in a text editor
- Edit the foreach loop on line 23 and add the following three lines:
foreach
(Telerik.OpenAccess.CodeGeneration.CodeClass @
class
in
@
namespace
.Classes)
{
var serializableAttr = @
class
.CreateAttribute();
serializableAttr.Name =
"Serializable"
;
@
class
.AddAttribute(serializableAttr);
this
.GeneratePerEntityFileBlock(@
class
as
Telerik.OpenAccess.CodeGeneration.CodeElement, @
namespace
, defaultExtension);
}
This way the Serializable attribute is added to each class before it is generated. Hope that helps.
Greetings,
Alexander
the Telerik team
OpenAccess ORM Q2'12 Now Available! Get your hands on all the new stuff.