Getting the Generated Classes to work in Silverlight - Part 2
Dernier message 13 janv. 2009 02:21 par solheim. 0 Réponses.
Version imprimable
Tri:
RetourRetour SuivantSuivant
Vous n'etes pas autorisé a poster une réponse.
Auteur Messages
solheim
New Member
New Member
Posts:11

--
13 janv. 2009 02:21  
Changes to Each BL Class Designer File.

Since Silverlight Factory methods must be ASynch, the following modifications.

#region "Factory Methods"
#if !SILVERLIGHT

All the existing factory methods with no modifications

#else

public static void NewRecord(EventHandler<DataPortalResult<BLProject>> handler)
public static void GetRecord(System.Int32 ProjectId, EventHandler<DataPortalResult<BLProject>> handler)
public static void DeleteRecord(System.Int32 ProjectId, EventHandler<DataPortalResult<BLProject>> handler)

EXCLUDED from Silverlight are Save() since we will use the Asynch BusinessBase.BeginSave(EventHandler<SavedEventArgs> handler) method.
EXCLUDED from Silverlight are the GetRecord(DTProject DTOProject) method since it will only run on the server in connection with DataAccess.

#endif

Examples of these Asynch Factory methods:

public static void NewRecord(EventHandler<DataPortalResult<BLProject>> handler)
{
if (!CanAddObject())
{
throw new System.Security.SecurityException("User not authorized to add data");
}

DataPortal<BLProject> dp = new DataPortal<BLProject>();
dp.CreateCompleted += handler;
dp.BeginCreate();
}


public static void GetRecord(System.Int32 ProjectId, EventHandler<DataPortalResult<BLProject>> handler)
{
if (!CanGetObject())
{
throw new System.Security.SecurityException("User not authorized to view a data");
}

DataPortal<BLProject> dp = new DataPortal<BLProject>();
dp.FetchCompleted += handler;
dp.BeginFetch(new SingleCriteria<BLProject, System.Int32>(ProjectId));
}


public static void DeleteRecord(System.Int32 ProjectId, EventHandler<DataPortalResult<BLProject>> handler)
{
if (!CanDeleteObject())
{
throw new System.Security.SecurityException("User not authorized to delete data");
}

DataPortal<BLProject> dp = new DataPortal<BLProject>();
dp.DeleteCompleted += handler;
dp.BeginDelete(new SingleCriteria<BLProject, System.Int32>(ProjectId));
}

End of Part 2 - More coming soon.

Paul Solheim
www.faktnet.com
Vous n'etes pas autorisé a poster une réponse.

Active Forums 4.1
NOT LICENSED FOR PRODUCTION USE
www.activemodules.com
Connexion / Inscription