Two applications of AOP: Entity set Update (dateentitylistupdate), deferred loading (lazyload) (top)
In Faibclass.data, there are two AOP applications, namely entity set Update (dateentitylistupdate), deferred loading (lazyload), and the current dataentity inherits from ContextBoundObject, Just from the Internet to see the loss of ContextBoundObject very large, but their own test, it should be said that the impact is not very large, so temporarily do not intend to use static injection.
Note, two AOP uses the Attribute--property--sink structure, each class's specific function please consult the related technical material.
I. Entity set UPDATE (dateentitylistupdate)
Set the properties of an entity in the foreground, when we update the entire entity set to the database, we do not know which attributes have changed, if all updates, will cause unnecessary waste, so introduced this concept. If we do not, each property set of the model class will add a code addupdatecolumn.
Used here. NET, because other AOP may also be used on entity classes.
Entitylistupdatableattribute class
//*******************************************************************
Module: Indicates that entity objects can be updated by collections
Date: 2009-7-29 1:05
Author: Faib
Copyrights: Copyright Faib Studio 2009
Official website: http://www.faib.net.cn
Email: faib920@126.com
Note:
//*******************************************************************
Using System;
Using System.Runtime.Remoting.Contexts;
Using System.Runtime.Remoting.Activation;
Using FaibClass.Data.Aspect;
Namespace Faibclass.data
{
<summary>
Indicates that a property change for an entity can be used to update the entire entity set, and if this attribute is not specified, the datastate of the entity cannot be modified.
</summary>
[AttributeUsage (AttributeTargets.Class, Allowmultiple=false)]
public class Entitylistupdatableattribute:attribute, Icontextattribute, Icontextproperty
{
Internal static string propertyname = "Entitylistupdatable";
<summary>
Constructs a property.
</summary>
Public Entitylistupdatableattribute ()
{
}
String Icontextproperty.name
{
get {return propertyname;}
}
void Icontextproperty.freeze (Context Newcontext)
{
}
BOOL Icontextproperty.isnewcontextok (Context Newctx)
{
return true;
}
void Icontextattribute.getpropertiesfornewcontext (IConstructionCallMessage ctormsg)
{
Icontextproperty interceptproperty = new Entitylistupdatableproperty ();
CTORMSG.CONTEXTPROPERTIES.ADD (Interceptproperty);
}
BOOL Icontextattribute.iscontextok (Context CTX, IConstructionCallMessage ctormsg)
{
if (CTX. GetProperty (propertyname) = = null)
{
return false;
}
return true;
}
}
}