This is the basic development mode:
/* Creator: the blog of caidao jushi
* Creation date: January 1, July 06, 2014
*/
Namespace net. CRM. organizationservice
{
Using system;
Using Microsoft. xrm. SDK;
Using Microsoft. xrm. SDK. query;
/// <Summary>
/// Basic mode --- organizationservice
/// </Summary>
Public class organizationservicedemo
{
/// <Summary>
/// Query
/// </Summary>
Public Entity retrieve (iorganizationservice service, entity en)
{
Return service. Retrieve (EN. logicalname, en. ID, new columnset ("new_int", "new_string "));
}
/// <Summary>
/// Delete
/// </Summary>
Public void Delete (iorganizationservice service, entity en)
{
Service. Delete (EN. logicalname, en. ID );
}
/// <Summary>
/// Batch Delete
/// </Summary>
Public void Delete (iorganizationservice service, entitycollection EC)
{
If (EC! = NULL & EC. Entities. Count> 0)
{
Foreach (entity en in EC. Entities)
{
Service. Delete (EN. logicalname, en. ID );
}
}
}
/// <Summary>
/// Update fields of the int type
/// </Summary>
Public void updateint (iorganizationservice service, entity en)
{
Entity updateen = new entity () {logicalname = en. logicalname, id = en. ID };
Updateen ["new_int"] = 10;
Service. Update (updateen );
}
/// <Summary>
/// Update a string field
/// </Summary>
Public void updateint (iorganizationservice service, entity en)
{
Entity updateen = new entity () {logicalname = en. logicalname, id = en. ID };
Updateen ["new_string"] = "ABC ";
Service. Update (updateen );
}
/// <Summary>
/// Update a float Field
/// </Summary>
Public void updatefloat (iorganizationservice service, entity en)
{
Entity updateen = new entity () {logicalname = en. logicalname, id = en. ID };
Updateen ["maid"] = 12.9;
Service. Update (updateen );
}
/// <Summary>
/// Update the money Field
/// </Summary>
Public void updatemoney (iorganizationservice service, entity en)
{
Entity updateen = new entity () {logicalname = en. logicalname, id = en. ID };
Updateen ["new_money"] = new money (12 );
Service. Update (updateen );
}
/// <Summary>
/// Update fields of the optionsetvalue type
/// </Summary>
Public void updateoptionsetvalue (iorganizationservice service, entity en)
{
Entity updateen = new entity () {logicalname = en. logicalname, id = en. ID };
Updateen ["new_optionsetvalue"] = new optionsetvalue (10 );
Service. Update (updateen );
}
/// <Summary>
/// Update fields of the entityreference type
/// </Summary>
Public void updateentityreference (iorganizationservice service, entity en)
{
Entity updateen = new entity () {logicalname = en. logicalname, id = en. ID };
Updateen ["new_account"] = new entityreference () {logicalname = "Account", id = guid. newguid ()};
Service. Update (updateen );
}
}
}
This is the improved mode:
/* Creator: the blog of caidao jushi
* Creation date: January 1, July 06, 2014
*/
Namespace net. CRM. organizationservice
{
Using system;
Using Microsoft. xrm. SDK;
Using Microsoft. xrm. SDK. query;
/// <Summary>
/// Quick development --- organizationservice
/// </Summary>
Public class organizationservicequickdemo
{
/// <Summary>
/// Query
/// </Summary>
Public Entity retrieve (iorganizationservice service, entity en)
{
Return service. Retrieve (EN, "new_int", "new_string ");
}
/// <Summary>
/// Delete
/// </Summary>
Public void Delete (iorganizationservice service, entity en)
{;
Service. Delete (en );
}
/// <Summary>
/// Batch Delete
/// </Summary>
Public void Delete (iorganizationservice service, entitycollection EC)
{
Service. Delete (EC );
}
/// <Summary>
/// Update fields of the int type
/// </Summary>
Public void updateint (iorganizationservice service, entity en)
{
Service. Update (EN, "new_int", 10 );
}
/// <Summary>
/// Update a string field
/// </Summary>
Public void updateint (iorganizationservice service, entity en)
{
Service. Update (EN, "new_string", "ABC ");
}
/// <Summary>
/// Update a float Field
/// </Summary>
Public void updatefloat (iorganizationservice service, entity en)
{
Service. Update (EN, "new_float", 12.9 );
}
/// <Summary>
/// Update the money Field
/// </Summary>
Public void updatemoney (iorganizationservice service, entity en)
{
Service. Update (EN, "new_money", new money (12 ));
}
/// <Summary>
/// Update fields of the optionsetvalue type
/// </Summary>
Public void updateoptionsetvalue (iorganizationservice service, entity en)
{
Service. Update (EN, "new_optionsetvalue", new optionsetvalue (10 ));
}
/// <Summary>
/// Update fields of the entityreference type
/// </Summary>
Public void updateentityreference (iorganizationservice service, entity en)
{
Service. Update (EN, "new_account", new entityreference () {logicalname = "Account", id = guid. newguid ()});
}
}
/// <Summary>
/// Extension Method
/// </Summary>
Public static class entityfunction
{
Public static entity retrieve (this iorganizationservice service, entity en, Params string [] attrs)
{
Return service. Retrieve (EN. logicalname, en. ID, new columnset (attrs ));
}
Public static void Delete (this iorganizationservice service, entity en)
{
Service. Delete (EN. logicalname, en. ID );
}
Public static void Delete (this iorganizationservice service, entitycollection EC)
{
If (EC! = NULL & EC. Entities. Count> 0)
{
Foreach (entity en in EC. Entities)
{
Service. Delete (EN. logicalname, en. ID );
}
}
}
Public static void update <t> (this iorganizationservice service, entity en, string name, T value)
{
Entity updateen = new entity () {logicalname = en. logicalname, id = en. ID };
Updateen [name] = value;
Service. Update (updateen );
}
}
}
Is development much faster.
Generally, if your project is not large enough time. At this time, there is no need to use quick development.
When your project is large, has many functions, and has a tight schedule, quick development is necessary.