Click here to Skip to main content
15,884,177 members
Articles / Web Development

Service Based Membership Providers for ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.93/5 (45 votes)
4 May 2014CPOL29 min read 131.5K   8.2K   173  
Service based, multi-application ASP.NET custom membership, role and profile providers with a hierarchical role system.
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool from CryptoGateway Software Inc.
//     Tool name: CGW X-Script RDB visual Layer Generator
//
//     Archymeta Information Technologies Co., Ltd.
//
//     Changes to this file, could be overwritten if the code is re-generated.
//     Add (if not yet) a code-manager node to the generator to specify 
//     how existing files are processed.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Configuration;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;

namespace CryptoGateway.RDB.Data.AspNetMember
{
    /// <summary>
    /// It is bound to webHttp end points accessed by javascript using json serialization method.
    /// </summary>
    /// <remarks>
    ///  <para>
    ///    Methods of the service are categorized in the following:
    ///  </para>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Adding, updating or Removing</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///         Adding, updating or removing entity graphs to or from data source.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///         <see cref="IRoleService.AddOrUpdateEntities" />, <see cref="IRoleService.EnqueueNewOrUpdateEntities" />, and <see cref="IRoleService.DeleteEntities" />.
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Paged Listing</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///         Provides paged listing of query results.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///         <see cref="IRoleService.NextPageBlock" /> and <see cref="IRoleService.GetPageItems" />,
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Querying</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Query the data source.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///         <see cref="IRoleService.QueryEntityCount" />, <see cref="IRoleService.QueryDatabase" />, <see cref="IRoleService.QueryDatabaseLimited" />,
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Entity Lookup</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Find an entity from the corresponding entity set.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///         <see cref="IRoleService.LoadEntityByKey" /> and <see cref="IRoleService.LoadEntityByNature" />,
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Conditioned Querying</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        When entities in an entity set depends on entities in other sets, query the data source under condition that some or all the entities that the current entity set depends on
    ///      are given.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///         <see cref="IRoleService.ConstraintQueryEntityCount" />, <see cref="IRoleService.ConstraintQuery" />, <see cref="IRoleService.ConstraintQueryLimited" />,
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Querying Intelligency</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///         Provides a self-complete system for clients to construct query expressions. What completeness means here is that all options are included and 
    ///      no extra (to the query system) options are present.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///         <see cref="IRoleService.GetNextSorterOps" /> and <see cref="IRoleService.GetNextFilterOps" />.
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Delay Loaded Properties</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Properties that are loaded on demand.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods (loading)</term>
    ///      <description>
    ///         <see cref="IRoleService.LoadEntityDescription" />
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods (uploading)</term>
    ///      <description>
    ///         <see cref="IRoleService.UpdateEntityDescription" />
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Entity Hierarchy</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Entity hierarchy load, navigation methods.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///        <see cref="IRoleService.LoadEntitySetRoots" />, <see cref="IRoleService.LoadEntityParent" />, <see cref="IRoleService.LoadEntityChildren" />,
    ///        <see cref="IRoleService.LoadEntityHierarchyRecurs" />, <see cref="IRoleService.LoadEntityFullHierarchyRecurs" />.
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Upstream Navigation</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Load and/or navigates to entities an entity in the current entity set depends upon.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///        <see cref="IRoleService.MaterializeApplication_Ref" />, <see cref="IRoleService.MaterializeUpperRef" />.
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Downstream Navigation</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Load and/or navigates to entity sets that depend on an entity in the current entity set.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///        <see cref="IRoleService.MaterializeRoles" />, <see cref="IRoleService.MaterializeUsersInRoles" />.
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Entity graph building</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Load a selected entity graph from the data source starting at an entity having specified primary key(s)
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///        <see cref="IRoleService.LoadEntityGraphRecurs" />.
    ///      </description>
    ///    </item>
    ///  </list>
    /// </remarks>
    [ServiceContract(Namespace = "http://relationaldb.archymeta.com/AspNetMember/", SessionMode = SessionMode.Allowed)]
    public interface IRoleService
    {
        /// <summary>
        ///   Retrieve information about the entity set: "Roles". 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="filter">Filter expression for the current set.</param>
        /// <returns>
        ///   Entity set: <see cref="RoleSet" /> data model.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/GetSetInfo")]
        RoleSet GetSetInfo(CallContext cntx, string filter);

        /// <summary>
        ///   Get a block of page frames from the entity set "Roles" of the data source under specified filtering and sorting conditions. 
        /// </summary>
        /// <remarks>
        /// The page size and the page block size is specified inside "set".
        /// </remarks>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <param name="prevlast">The last entity inside the previous page block. For the first page block, it is set to null value.</param>
        /// <returns>
        ///   <see cref="RolePageBlock" /> data model for entity set "Roles".
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/NextPageBlock")]
        RolePageBlock NextPageBlock(CallContext cntx, RoleSet set, QueryExpresion qexpr, Role prevlast);

        /// <summary>
        ///   Load entities of a page from the entity set "Roles" of the data source under specified filtering and sorting conditions. 
        /// </summary>
        /// <remarks>
        /// The page size is specified inside "set".
        /// </remarks>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <param name="prevlast">The last entity inside the previous page. For the first page, it is set to null value.</param>
        /// <returns>
        ///   Collection of <see cref="Role" /> in set "Roles" for the current page defined by "prevlast".
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/GetPageItems")]
        IEnumerable<Role> GetPageItems(CallContext cntx, RoleSet set, QueryExpresion qexpr, Role prevlast);

        /// <summary>
        ///   Add or update a set of entities to the entity set. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">The current entity set.</param>
        /// <param name="entities">The list of entities to be processed.</param>
        /// <remarks>
        ///  <para>
        ///  The list of entities will be checked against existing ones inside the entity set. An entity is identified by a set of "intrinsic identitfiers" selected
        ///  when the system is generated. They are not necessarily the same as primary keys of the set. An auto generated primary key can not be
        ///  used as an "intrinsic identitfier". An entity having the same set of "intrinsic identitfiers" can not be added to the database. They will be treated 
        ///  as an entity update if the client load the entity first before modifying it, otherwise (namely if the client created the entity on the client side),
        ///  the update will be rejected unless the client set the <see cref="CallContext.OverrideExisting" /> property  of "cntx" to <c>true</c>. </para>
        ///  <para>
        ///  Note: entities having no "intrinsic identitfier" will always be treated as different entities in add operations. 
        ///  </para>
        ///  <para>
        ///  Note 2: A persisted entity (namely the one loaded
        ///  from the data set) will be ignored in if none of its editable properties (set before system generation, see
        ///  <see cref="Role" />) is modified or its <see cref="Role.IsEntityChanged" /> property is
        ///  not set to <c>true</c>. 
        ///  </para>
        ///  <para>
        ///  Clients can set some of the member entities in { <see cref="Role.Application_Ref" />, <see cref="Role.UpperRef" /> } that an currently added or updated entity depends upon. These additional entities will be 
        ///  add or updated to the data source following the same logic, all the object relationships will be properly setup if the operation is successful.
        ///  </para>
        ///  <para>
        ///  Clients can also create and add to member collections in { <see cref="Role.ChangedRoles" />, <see cref="Role.ChangedUsersInRoles" /> } entities that depends on an currently added or updated entity. These 
        ///  additional entities will be add or updated to the data source following the same logic, all the object relationships will be properly setup if the operation is successful.
        ///  </para>
        ///  <para>
        ///  In general, a client can construct an object graph of any complexity following the above rules and have it added or updated to the data source in one step.
        ///  </para>
        /// </remarks>
        /// <returns>
        ///   Operation result contained inside an object of type <see cref="ChangeOpResults{T}" /> which contains operation messages, if any, and a list of successfully added or updated entities.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/AddOrUpdateEntities")]
        ChangeOpResults<RoleUpdateResult> AddOrUpdateEntities(CallContext cntx, RoleSet set, Role[] entities);

        /// <summary>
        ///   Queue a set of entities to be added or updated to the entity set in a certain preset future time. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">The current entity set.</param>
        /// <param name="entities">The list of entities to be processed.</param>
        /// <remarks>
        ///  <para>
        ///  The processing will be delayed to be started at a certain future time. If there are any further calls to this method during the wait period, the new sets will be 
        ///  merged with existing ones inside the queue. This method is useful when there are repetitive updates to the entity set but the actual change history is not of 
        ///  interest to the client, namely only the last snapshot of the changes are relevent. In this case, the method can reduce the loads on the backend data source 
        ///  significantly.
        ///  </para>
        ///  <para>
        ///  The list of entities will be checked against existing ones inside the entity set when the processing starts. An entity is identified by a set of "intrinsic identitfiers" selected
        ///  when the system is generated. They are not necessarily the same as primary keys of the set. An auto generated primary key can not be
        ///  used as an "intrinsic identitfier". An entity having the same set of "intrinsic identitfiers" can not be added to the database. They will be treated 
        ///  as an entity update if the client load the entity first before modifying it, otherwise (namely if the client created the entity on the client side), 
        ///  the update will be rejected unless the client set the <c>OverrideExisting</c> property  of "cntx" to <c>true</c>. 
        ///  </para>
        ///  <para>
        ///  Note: entities having no "intrinsic identitfier" will always be treated as different entities in add or update operations, namely they will always be added to the set.
        ///  </para>
        ///  <para>
        ///  Note 2: A persisted entity (namely the one loaded
        ///  from the data set) will be ignored in if none of its editable properties (set before system generation, see
        ///  <see cref="Role" />) is modified or its <see cref="Role.IsEntityChanged" /> property is
        ///  not set to <c>true</c>. 
        ///  </para>
        ///  <para>
        ///  Warning: Please do not use this method when new entities are to be added and information about these updated enitities, like auto generated primary keys, are needed for 
        ///  proceeding to the next steps.
        ///  </para>
        ///  <para>
        ///  Clients can set some of the member entities in { <see cref="Role.Application_Ref" />, <see cref="Role.UpperRef" /> } that an currently added or updated entity depends upon. These additional entities will be 
        ///  add or updated to the data source following the same logic, all the object relationships will be properly setup if the operation is successful.
        ///  </para>
        ///  <para>
        ///  Clients can also create and add to member collections in { <see cref="Role.ChangedRoles" />, <see cref="Role.ChangedUsersInRoles" /> } entities that depends on an currently added or updated entity. These 
        ///  additional entities will be add or updated to the data source following the same logic, all the object relationships will be properly setup if the operation is successful.
        ///  </para>
        ///  <para>
        ///  In general, a client can construct an object graph of any complexity following the above rules and have it added or updated to the data source in one step.
        ///  </para>
        /// </remarks>
        /// <returns>
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/EnqueueNewOrUpdateEntities")]
        void EnqueueNewOrUpdateEntities(CallContext cntx, RoleSet set, Role[] entities);

        /// <summary>
        ///  Delete a set of entities from the entity set, together with all their dependents, recursively. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">The current entity set.</param>
        /// <param name="entities">The list of entities to be processed.</param>
        /// <remarks>
        ///  <para>
        ///   Care should be taken when deleting an entire inter-dependent object sub-graph.
        ///  </para>
        /// </remarks>
        /// <returns>
        ///   Operation result contained inside an object of type <see cref="OperationResults" /> which contains operation messages, if any.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/DeleteEntities")]
        OperationResults DeleteEntities(CallContext cntx, RoleSet set, Role[] entities);

        /// <summary>
        ///   Count the number of entities inside entity set "Roles" of the data source under specified filtering condition. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   The number of entities.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/QueryEntityCount")]
        Int64 QueryEntityCount(CallContext cntx, RoleSet set, QueryExpresion qexpr);

        /// <summary>
        ///   Get the collection of entities of type <see cref="Role" /> inside entity set "Roles" of the data source under specified filtering and sorting conditions. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   The collection of entities.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/QueryDatabase")]
        IEnumerable<Role> QueryDatabase(CallContext cntx, RoleSet set, QueryExpresion qexpr);

        /// <summary>
        ///   Get the collection of entities of type <see cref="Role" /> inside entity set "Roles" from the data source under specified filtering, sorting and max number of returning entities conditions. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <param name="maxRecords">Max number of entities to return.</param>
        /// <returns>
        ///   The collection of entities.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/QueryDatabaseLimited")]
        IEnumerable<Role> QueryDatabaseLimited(CallContext cntx, RoleSet set, QueryExpresion qexpr, int maxRecords);

        /// <summary>
        ///   Get the number of entities from the data source restricted by a set of specified foreign key values and under specified filtering, sorting conditions. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="constraints">A set of foreign key wrapper pointing to primary keys of the sets that "Roles" depends upon. If a user do not wish to set a contraint for it, then set it to null, </param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   The number of entities.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/ConstraintQueryEntityCount")]
        Int64 ConstraintQueryEntityCount(CallContext cntx, RoleSet set, RoleSetConstraints constraints, QueryExpresion qexpr);

        /// <summary>
        ///   Given a set of foreign key constraints, find the ones that has non zero corresponding entities. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="cnstSets">A collection of sets of foreign key wrapper pointing to primary keys of the sets that "Roles" depends upon. If a user do not wish to set a contraint for it, then set it to null, </param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   A set of constraint pointer that has non-zero corresponding entities.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/ConstraintsFindMatches")]
        ConstraintsPtr[] ConstraintsFindMatches(CallContext cntx, RoleSet set, RoleSetConstraints[] cnstSets, QueryExpresion qexpr);

        /// <summary>
        ///   Get the collection of entities of type <see cref="Role" /> inside entity set "Roles" from the data source restricted by a set of specified foreign key values and under specified filtering, sorting conditions. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="constraints">A set of foreign key wrapper pointing to primary keys of the sets that "Roles" depends upon. If a user do not wish to set a contraint for it, then set it to null, </param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   The collection of entities.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/ConstraintQuery")]
        IEnumerable<Role> ConstraintQuery(CallContext cntx, RoleSet set, RoleSetConstraints constraints, QueryExpresion qexpr);

        /// <summary>
        ///   Get the collection of entities of type <see cref="Role" /> inside entity set "Roles" of the data source restricted by a set of specified foreign key values and under specified filtering, sorting and max number of returning entities conditions. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="constraints">A set of foreign key wrapper pointing to primary keys of the sets that "Roles" depends upon. If a user do not wish to set a contraint for it, then set it to null, </param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <param name="maxRecords">Max number of entities to return.</param>
        /// <returns>
        ///   The collection of entities.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/ConstraintQueryLimited")]
        IEnumerable<Role> ConstraintQueryLimited(CallContext cntx, RoleSet set, RoleSetConstraints constraints, QueryExpresion qexpr, int maxRecords);

        /// <summary>
        ///   Load the entity "Application_Ref" of type <see cref="Application_" /> that the entity depend upon. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <remarks>
        /// If the corresponding foreign key is nullable, the returned entity can be null.
        /// </remarks>
        /// <returns>
        ///   An entity of type <see cref="Application_" /> or null.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/MaterializeApplication_Ref")]
        Application_ MaterializeApplication_Ref(CallContext cntx, Role entity);

        /// <summary>
        ///   Load the entity "UpperRef" of type <see cref="Role" /> that the entity depend upon. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <remarks>
        /// If the corresponding foreign key is nullable, the returned entity can be null.
        /// </remarks>
        /// <returns>
        ///   An entity of type <see cref="Role" /> or null.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/MaterializeUpperRef")]
        Role MaterializeUpperRef(CallContext cntx, Role entity);

        /// <summary>
        ///   Get the collection of non-trivial foreign key constrains of type <see cref="Role" /> inside entity set "Roles" of the data source under specified filtering and sorting conditions. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Filter expression for the set.</param>
        /// <param name="max">Number of items per page.</param>
        /// <param name="nextId">The id of next page, if any.</param>
        /// <returns>
        ///   The collection of independent non-trivial foreign key constrains.
        /// </returns>
        /// <remarks>It will throw an exception if the <see cref="RoleSet.SetFilter" /> of <paramref name="set" /> is null or empty.</remarks>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/QuerySetConstraints")]
        RoleSetConstraintsColl QuerySetConstraints(CallContext cntx, RoleSet set, QueryExpresion qexpr, int max, string nextId);

        /// <summary>
        ///   Load the set of depending entities "Roles" of type <see cref="RoleSet" /> of the entity. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <remarks>
        ///  The set returned is a filtered subset whose members are all depending on the entity.
        /// </remarks>
        /// <returns>
        ///   An entity of type <see cref="RoleSet" />.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/MaterializeRoles")]
        RoleSet MaterializeRoles(CallContext cntx, Role entity);

        /// <summary>
        ///   Load the collection of depending entities "AllRoles" of type <see cref="IEnumerable{Role}" /> (T = <see cref="Role" />) of the entity. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <returns>
        ///   An collecton of type <see cref="IEnumerable{Role}" /> (T = <see cref="Role" />).
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/MaterializeAllRoles")]
        IEnumerable<Role> MaterializeAllRoles(CallContext cntx, Role entity);

        /// <summary>
        ///   Load the set of depending entities "UsersInRoles" of type <see cref="UsersInRoleSet" /> of the entity. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <remarks>
        ///  The set returned is a filtered subset whose members are all depending on the entity.
        /// </remarks>
        /// <returns>
        ///   An entity of type <see cref="UsersInRoleSet" />.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/MaterializeUsersInRoles")]
        UsersInRoleSet MaterializeUsersInRoles(CallContext cntx, Role entity);

        /// <summary>
        ///   Load the collection of depending entities "AllUsersInRoles" of type <see cref="IEnumerable{UsersInRole}" /> (T = <see cref="UsersInRole" />) of the entity. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <returns>
        ///   An collecton of type <see cref="IEnumerable{UsersInRole}" /> (T = <see cref="UsersInRole" />).
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/MaterializeAllUsersInRoles")]
        IEnumerable<UsersInRole> MaterializeAllUsersInRoles(CallContext cntx, Role entity);

        /// <summary>
        ///  Load an entity from the entity set having specified primary key(s): { <see cref="Role.ID" /> }. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_ID">Primary key <see cref="Role.ID" />.</param>
        /// <returns>
        ///   Null or the entity found.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/LoadEntityByKey")]
        Role LoadEntityByKey(CallContext cntx, int _ID);

        /// <summary>
        ///  Load a selected entity graph from the data source starting at an entity having specified primary key(s): { <see cref="Role.ID" /> }. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_ID">Primary key <see cref="Role.ID" />.</param>
        /// <param name="excludedSets">A list of sets to be excluded. </param>
        /// <param name="futherDrillSets">A list of sets above the entry set that are to be drilled down futher (see the following). </param>
        /// <remarks>
        /// <para>Relational databases are designed to serve as data query and storage backend, in a normalized way, for certain kind of applications. 
        /// However at the application level, normalized elementary data sets are often combined (jointed) in a user friendly way as views. In the object oriented 
        /// world and at the data view model level, these views can be represented using entity graphs.</para>
        /// <para>This method is designed to load a selected sub entity graph recursively starting from a given entity (id) from the data source in one call 
        /// to the service, which could be used to increase performance and to reduce client code complexity, sometimes significantly.</para>
        /// <para>The selection is controlled by the two parameters, namely <paramref name="excludedSets" /> and <paramref name="futherDrillSets" />.</para>
        /// <para>The <paramref name="excludedSets" /> parameter is used to exclude a list of entity sets and all other sets that depend on it. This can be
        /// better understood if one has a look at the schematic view of the data set schema that is shown on the front page of the data service, namely
        /// if one date set (node) is excluded then all the sets that it points to will not be reached through it, although some of them could still be reached
        /// following other routes. </para>
        /// <para>There are many ways an entity sub-graph can be loaded, the present implementation is based on the rule to be given next. Namely, starting from 
        /// entry element, it loads all entities that depends on it, recursively downward (namely following the arrows in the schema view). It also load all 
        /// elements that any of the elements visited by the downward recursion depends upon, recursively upward (namely in 
        /// the opposite direction of the arrows in the schema view), but never go downward again without explicit instruction.</para>
        /// <para>The <paramref name="futherDrillSets" /> parameter is used control when to go downward again, represented by the <see cref="EntitySetRelation.SetType" /> member 
        /// and the collection of data sets that depend on it, represented by the <see cref="EntitySetRelation.RelatedSets" /> member, should be further drilled down, recursively.</para>
        /// <para>Note that a data service has intrinsic limits that does not allow transimitting an entity graph that is too large in one call, so one has to select which part
        /// of the entire graph should be loaded in each call to the data service,</para>
        /// <para>For a given entity, the entities that it depends upon are represented by the member objects corresponding to each foreign keys. However, the
        /// sets of entities that depend on the said entity are stored into the corresponding collection members having the "Changed" prefix and
        /// these entities do not have a back reference to the said entity to avoid circular references when doing serialization, Such back references can be
        /// added after the graph is materialized on the clients side, if needed.</para>
        /// </remarks>
        /// <returns>
        ///   Null or the entity graph found.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/LoadEntityGraphRecurs")]
        Role LoadEntityGraphRecurs(CallContext cntx, int _ID, EntitySetType[] excludedSets, EntitySetRelation[] futherDrillSets);

        /// <summary>
        ///  Load a set entities from the entity set having specified intrinsic ids: { <see cref="Role.RoleName" />, <see cref="Role.ApplicationID" />, <see cref="Role.ParentID" /> }. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_RoleName">Intrinsic id <see cref="Role.RoleName" />.</param>
        /// <param name="_ApplicationID">Intrinsic id <see cref="Role.ApplicationID" />.</param>
        /// <param name="_ParentID">Intrinsic id <see cref="Role.ParentID" />.</param>
        /// <remarks>
        ///  <para>
        ///   If the intrinsic identifiers are well chosen, the returned entity set should contain zero or one item. This could not be the case
        ///   if the system is attached to an existing database whose data were entered without respecting the rules (namely those entities having the
        ///   same set of intrinsic identifiers should appear only once inside the data source) imposed later by the
        ///   system.
        ///  </para>
        /// </remarks>
        /// <returns>
        ///   The list of found entities.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/LoadEntityByNature")]
        List<Role> LoadEntityByNature(CallContext cntx, string _RoleName, string _ApplicationID, System.Nullable<int> _ParentID);

        /// <summary>
        ///  For a hierarchic data set, load a set root entities from the entity set. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <remarks>
        ///  A root entity is one that have no dependency on other entities inside the same data set, or its foreign key <see cref="Role.ParentID" /> = null.
        /// </remarks>
        /// <returns>
        ///   A set of wrapped root entities.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/LoadEntitySetRoots")]
        IEnumerable<EntityAbs<Role>> LoadEntitySetRoots(CallContext cntx);

        /// <summary>
        ///  For a hierarchic data set, load a wrapped parent node of a node from the entity set. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="node">The wrapped node under consideration.</param>
        /// <remarks>
        /// </remarks>
        /// <returns>
        ///   Null or a wrapped parent entity.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/LoadEntityParent")]
        EntityAbs<Role> LoadEntityParent(CallContext cntx, EntityAbs<Role> node);

        /// <summary>
        ///  For a hierarchic data set, load a collection of wrapped child nodes of a node from the entity set. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="node">The wrapped node under consideration.</param>
        /// <remarks>
        /// </remarks>
        /// <returns>
        ///   A collection of wrapped child entities.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/LoadEntityChildren")]
        IEnumerable<EntityAbs<Role>> LoadEntityChildren(CallContext cntx, EntityAbs<Role> node);

        /// <summary>
        ///  For a hierarchic data set, load the entire tree of wrapped nodes from the entity set, starting from any member node. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The starting entity under consideration.</param>
        /// <remarks>
        ///  Loading a tree in one call to the database can increase the performance by reducing the number of calls to the data service.
        /// </remarks>
        /// <returns>
        ///   The wrapped root entity of the tree.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/LoadEntityFullHierarchyRecurs")]
        EntityAbs<Role> LoadEntityFullHierarchyRecurs(CallContext cntx, Role entity);

        /// <summary>
        ///   For a hierarchic data set, load a sub-tree of wrapped nodes with maximum relative height and relative depth from the entity set starting from any member node. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The starting entity under consideration.</param>
        /// <param name="uplev">Include parent nodes of the starting node, together with all the sibling trees under them, up to this value in relative height. If the value is -1, then all 
        ///    of the parent nodes and sibling trees (if any) will be included,</param>
        /// <param name="lowlev">Include child nodes of the starting node down to this value in relative depth. If the value is -1, then all of the child nodes will be included,</param>
        /// <remarks>
        /// For a large tree, this method can help the clients to load only a partial tree with limited hight and depth that is connected to the starting node.
        /// Loading a partial tree in one call to the database can increase the performance by reducing the number of calls to the data service.
        /// </remarks>
        /// <returns>
        ///   The wrapped root entity of the partial tree.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/LoadEntityHierarchyRecurs")]
        EntityAbs<Role> LoadEntityHierarchyRecurs(CallContext cntx, Role entity, int uplev, int lowlev);

        /// <summary>
        ///  Load the delay loaded property <see cref="Role.Description" />. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_ID">Primary key <see cref="Role.ID" />.</param>
        /// <remarks>
        /// </remarks>
        /// <returns>
        ///   The value of the property.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/LoadEntityDescription")]
        string LoadEntityDescription(CallContext cntx, int _ID);

        /// <summary>
        ///  Update the delay loaded property <see cref="Role.Description" />. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_ID">Primary key <see cref="Role.ID" />.</param>
        /// <param name="data">The updated value.</param>
        /// <remarks>
        /// </remarks>
        /// <returns>
        ///   The value of the property.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/UpdateEntityDescription")]
        void UpdateEntityDescription(CallContext cntx, int _ID, string data);

        /// <summary>
        ///  Given the current sorter expression <paramref name="sorters" />, it returns the next sorter token options. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="sorters">Sorter expression tokens.</param>
        /// <returns>
        ///   A list of possible sort tokens.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/GetNextSorterOps")]
        TokenOptions GetNextSorterOps(CallContext cntx, List<QToken> sorters);

        /// <summary>
        ///  Given the current query expression <paramref name="qexpr" />, it returns the next filter token options. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="qexpr">The current query expression.</param>
        /// <param name="tkstr">Partial user input to filter the options further. It is not used on the service side in the current version of the system.</param>
        /// <returns>
        ///   A list of possible filter tokens.
        /// </returns>
        [OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "/GetNextFilterOps")]
        TokenOptions GetNextFilterOps(CallContext cntx, QueryExpresion qexpr, string tkstr);

    }

    /// <summary>
    /// It is bound to basicHttp end points accessed by clients other than a web browser.
    /// </summary>
    /// <remarks>
    ///  <para>
    ///    Methods of the service are categorized in the following:
    ///  </para>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Adding, updating or Removing</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///         Adding, updating or removing entity graphs to or from data source.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///         <see cref="IRoleService2.AddOrUpdateEntities" />, <see cref="IRoleService2.EnqueueNewOrUpdateEntities" />, and <see cref="IRoleService2.DeleteEntities" />.
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Paged Listing</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///         Provides paged listing of query results.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///         <see cref="IRoleService2.NextPageBlock" /> and <see cref="IRoleService2.GetPageItems" />,
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Querying</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Query the data source.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///         <see cref="IRoleService2.QueryEntityCount" />, <see cref="IRoleService2.QueryDatabase" />, <see cref="IRoleService2.QueryDatabaseLimited" />,
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Entity Lookup</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Find an entity from the corresponding entity set.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///         <see cref="IRoleService2.LoadEntityByKey" /> and <see cref="IRoleService2.LoadEntityByNature" />,
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Conditioned Querying</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        When entities in an entity set depends on entities in other sets, query the data source under condition that some or all the entities that the current entity set depends on
    ///      are given.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///         <see cref="IRoleService2.ConstraintQueryEntityCount" />, <see cref="IRoleService2.ConstraintQuery" />, <see cref="IRoleService2.ConstraintQueryLimited" />,
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Querying Intelligency</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///         Provides a self-complete system for clients to construct query expressions. What completeness means here is that all options are included and 
    ///      no extra (to the query system) options are present.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///         <see cref="IRoleService2.GetNextSorterOps" /> and <see cref="IRoleService2.GetNextFilterOps" />.
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Delay Loaded Properties</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Properties that are loaded on demand.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods (loading)</term>
    ///      <description>
    ///         <see cref="IRoleService2.LoadEntityDescription" />
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods (uploading)</term>
    ///      <description>
    ///         <see cref="IRoleService2.UpdateEntityDescription" />
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Entity Hierarchy</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Entity hierarchy load, navigation methods.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///        <see cref="IRoleService2.LoadEntitySetRoots" />, <see cref="IRoleService2.LoadEntityParent" />, <see cref="IRoleService2.LoadEntityChildren" />,
    ///        <see cref="IRoleService2.LoadEntityHierarchyRecurs" />, <see cref="IRoleService2.LoadEntityFullHierarchyRecurs" />.
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Upstream Navigation</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Load and/or navigates to entities an entity in the current entity set depends upon.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///        <see cref="IRoleService2.MaterializeApplication_Ref" />, <see cref="IRoleService2.MaterializeUpperRef" />.
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Downstream Navigation</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Load and/or navigates to entity sets that depend on an entity in the current entity set.
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///        <see cref="IRoleService2.MaterializeRoles" />, <see cref="IRoleService2.MaterializeUsersInRoles" />.
    ///      </description>
    ///    </item>
    ///  </list>
    ///  <list type="table">
    ///    <listheader>
    ///       <term>Entity graph building</term><description></description>
    ///    </listheader>
    ///    <item>
    ///      <term>Description</term>
    ///      <description>
    ///        Load a selected entity graph from the data source starting at an entity having specified primary key(s)
    ///      </description>
    ///    </item>
    ///    <item>
    ///      <term>Methods</term>
    ///      <description>
    ///        <see cref="IRoleService2.LoadEntityGraphRecurs" />.
    ///      </description>
    ///    </item>
    ///  </list>
    /// </remarks>
    [ServiceContract(Namespace = "http://relationaldb.archymeta.com/AspNetMember/", SessionMode = SessionMode.Allowed)]
    public interface IRoleService2
    {
        /// <summary>
        ///   Retrieve information about the entity set: "Roles". 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="filter">Filter expression for the current set.</param>
        /// <returns>
        ///   Entity set: <see cref="RoleSet" /> data model.
        /// </returns>
        [OperationContract]
        RoleSet GetSetInfo(CallContext cntx, string filter);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Retrieve information about the entity set: "Roles". Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="filter">Filter expression for the current set.</param>
        /// <returns>
        ///   Entity set: <see cref="RoleSet" /> data model.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<RoleSet> GetSetInfoAsync(CallContext cntx, string filter);
#endif

        /// <summary>
        ///   Get a block of page frames from the entity set "Roles" of the data source under specified filtering and sorting conditions. 
        /// </summary>
        /// <remarks>
        /// The page size and the page block size is specified inside "set".
        /// </remarks>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <param name="prevlast">The last entity inside the previous page block. For the first page block, it is set to null value.</param>
        /// <returns>
        ///   <see cref="RolePageBlock" /> data model for entity set "Roles".
        /// </returns>
        [OperationContract]
        RolePageBlock NextPageBlock(CallContext cntx, RoleSet set, QueryExpresion qexpr, Role prevlast);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Get a block of page frames from the entity set "Roles" of the data source under specified filtering and sorting conditions. Awaitable asynchronous version.
        /// </summary>
        /// <remarks>
        /// The page size and the page block size is specified inside "set".
        /// </remarks>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <param name="prevlast">The last entity inside the previous page block. For the first page block, it is set to null value.</param>
        /// <returns>
        ///   <see cref="RolePageBlock" /> data model for entity set "Roles".
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<RolePageBlock> NextPageBlockAsync(CallContext cntx, RoleSet set, QueryExpresion qexpr, Role prevlast);
#endif

        /// <summary>
        ///   Load entities of a page from the entity set "Roles" of the data source under specified filtering and sorting conditions. 
        /// </summary>
        /// <remarks>
        /// The page size is specified inside "set".
        /// </remarks>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <param name="prevlast">The last entity inside the previous page. For the first page, it is set to null value.</param>
        /// <returns>
        ///   Collection of <see cref="Role" /> in set "Roles" for the current page defined by "prevlast".
        /// </returns>
        [OperationContract]
        IEnumerable<Role> GetPageItems(CallContext cntx, RoleSet set, QueryExpresion qexpr, Role prevlast);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Load entities of a page from the entity set "Roles" of the data source under specified filtering and sorting conditions. Awaitable asynchronous version.
        /// </summary>
        /// <remarks>
        /// The page size is specified inside "set".
        /// </remarks>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <param name="prevlast">The last entity inside the previous page. For the first page, it is set to null value.</param>
        /// <returns>
        ///   Collection of <see cref="Role" /> in set "Roles" for the current page defined by "prevlast".
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<IEnumerable<Role>> GetPageItemsAsync(CallContext cntx, RoleSet set, QueryExpresion qexpr, Role prevlast);
#endif

        /// <summary>
        ///   Add or update a set of entities to the entity set. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">The current entity set.</param>
        /// <param name="entities">The list of entities to be processed.</param>
        /// <remarks>
        ///  <para>
        ///  The list of entities will be checked against existing ones inside the entity set. An entity is identified by a set of "intrinsic identitfiers" selected
        ///  when the system is generated. They are not necessarily the same as primary keys of the set. An auto generated primary key can not be
        ///  used as an "intrinsic identitfier". An entity having the same set of "intrinsic identitfiers" can not be added to the database. They will be treated 
        ///  as an entity update if the client load the entity first before modifying it, otherwise (namely if the client created the entity on the client side),
        ///  the update will be rejected unless the client set the <see cref="CallContext.OverrideExisting" /> property  of "cntx" to <c>true</c>. </para>
        ///  <para>
        ///  Note: entities having no "intrinsic identitfier" will always be treated as different entities in add operations. 
        ///  </para>
        ///  <para>
        ///  Note 2: A persisted entity (namely the one loaded
        ///  from the data set) will be ignored in if none of its editable properties (set before system generation, see
        ///  <see cref="Role" />) is modified or its <see cref="Role.IsEntityChanged" /> property is
        ///  not set to <c>true</c>. 
        ///  </para>
        ///  <para>
        ///  Clients can set some of the member entities in { <see cref="Role.Application_Ref" />, <see cref="Role.UpperRef" /> } that an currently added or updated entity depends upon. These additional entities will be 
        ///  add or updated to the data source following the same logic, all the object relationships will be properly setup if the operation is successful.
        ///  </para>
        ///  <para>
        ///  Clients can also create and add to member collections in { <see cref="Role.ChangedRoles" />, <see cref="Role.ChangedUsersInRoles" /> } entities that depends on an currently added or updated entity. These 
        ///  additional entities will be add or updated to the data source following the same logic, all the object relationships will be properly setup if the operation is successful.
        ///  </para>
        ///  <para>
        ///  In general, a client can construct an object graph of any complexity following the above rules and have it added or updated to the data source in one step.
        ///  </para>
        /// </remarks>
        /// <returns>
        ///   Operation result contained inside an object of type <see cref="ChangeOpResults{T}" /> which contains operation messages, if any, and a list of successfully added or updated entities.
        /// </returns>
        [OperationContract]
        ChangeOpResults<RoleUpdateResult> AddOrUpdateEntities(CallContext cntx, RoleSet set, Role[] entities);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Add or update a set of entities to the entity set. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">The current entity set.</param>
        /// <param name="entities">The list of entities to be processed.</param>
        /// <remarks>
        ///  <para>
        ///  The list of entities will be checked against existing ones inside the entity set. An entity is identified by a set of "intrinsic identitfiers" selected
        ///  when the system is generated. They are not necessarily the same as primary keys of the set. An auto generated primary key can not be
        ///  used as an "intrinsic identitfier". An entity having the same set of "intrinsic identitfiers" can not be added to the database. They will be treated 
        ///  as an entity update if the client load the entity first before modifying it, otherwise (namely if the client created the entity on the client side),
        ///  the update will be rejected unless the client set the <see cref="CallContext.OverrideExisting" /> property  of "cntx" to <c>true</c>. </para>
        ///  <para>
        ///  Note: entities having no "intrinsic identitfier" will always be treated as different entities in add operations. 
        ///  </para>
        ///  <para>
        ///  Note 2: A persisted entity (namely the one loaded
        ///  from the data set) will be ignored in if none of its editable properties (set before system generation, see
        ///  <see cref="Role" />) is modified or its <see cref="Role.IsEntityChanged" /> property is
        ///  not set to <c>true</c>. 
        ///  </para>
        ///  <para>
        ///  Clients can set some of the member entities in { <see cref="Role.Application_Ref" />, <see cref="Role.UpperRef" /> } that an currently added or updated entity depends upon. These additional entities will be 
        ///  add or updated to the data source following the same logic, all the object relationships will be properly setup if the operation is successful.
        ///  </para>
        ///  <para>
        ///  Clients can also create and add to member collections in { <see cref="Role.ChangedRoles" />, <see cref="Role.ChangedUsersInRoles" /> } entities that depends on an currently added or updated entity. These 
        ///  additional entities will be add or updated to the data source following the same logic, all the object relationships will be properly setup if the operation is successful.
        ///  </para>
        ///  <para>
        ///  In general, a client can construct an object graph of any complexity following the above rules and have it added or updated to the data source in one step.
        ///  </para>
        /// </remarks>
        /// <returns>
        ///   Operation result contained inside an object of type <see cref="ChangeOpResults{T}" /> which contains operation messages, if any, and a list of successfully added or updated entities.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<ChangeOpResults<RoleUpdateResult>> AddOrUpdateEntitiesAsync(CallContext cntx, RoleSet set, Role[] entities);
#endif

        /// <summary>
        ///   Queue a set of entities to be added or updated to the entity set in a certain preset future time. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">The current entity set.</param>
        /// <param name="entities">The list of entities to be processed.</param>
        /// <remarks>
        ///  <para>
        ///  The processing will be delayed to be started at a certain future time. If there are any further calls to this method during the wait period, the new sets will be 
        ///  merged with existing ones inside the queue. This method is useful when there are repetitive updates to the entity set but the actual change history is not of 
        ///  interest to the client, namely only the last snapshot of the changes are relevent. In this case, the method can reduce the loads on the backend data source 
        ///  significantly.
        ///  </para>
        ///  <para>
        ///  The list of entities will be checked against existing ones inside the entity set when the processing starts. An entity is identified by a set of "intrinsic identitfiers" selected
        ///  when the system is generated. They are not necessarily the same as primary keys of the set. An auto generated primary key can not be
        ///  used as an "intrinsic identitfier". An entity having the same set of "intrinsic identitfiers" can not be added to the database. They will be treated 
        ///  as an entity update if the client load the entity first before modifying it, otherwise (namely if the client created the entity on the client side), 
        ///  the update will be rejected unless the client set the <c>OverrideExisting</c> property  of "cntx" to <c>true</c>. 
        ///  </para>
        ///  <para>
        ///  Note: entities having no "intrinsic identitfier" will always be treated as different entities in add or update operations, namely they will always be added to the set.
        ///  </para>
        ///  <para>
        ///  Note 2: A persisted entity (namely the one loaded
        ///  from the data set) will be ignored in if none of its editable properties (set before system generation, see
        ///  <see cref="Role" />) is modified or its <see cref="Role.IsEntityChanged" /> property is
        ///  not set to <c>true</c>. 
        ///  </para>
        ///  <para>
        ///  Warning: Please do not use this method when new entities are to be added and information about these updated enitities, like auto generated primary keys, are needed for 
        ///  proceeding to the next steps.
        ///  </para>
        ///  <para>
        ///  Clients can set some of the member entities in { <see cref="Role.Application_Ref" />, <see cref="Role.UpperRef" /> } that an currently added or updated entity depends upon. These additional entities will be 
        ///  add or updated to the data source following the same logic, all the object relationships will be properly setup if the operation is successful.
        ///  </para>
        ///  <para>
        ///  Clients can also create and add to member collections in { <see cref="Role.ChangedRoles" />, <see cref="Role.ChangedUsersInRoles" /> } entities that depends on an currently added or updated entity. These 
        ///  additional entities will be add or updated to the data source following the same logic, all the object relationships will be properly setup if the operation is successful.
        ///  </para>
        ///  <para>
        ///  In general, a client can construct an object graph of any complexity following the above rules and have it added or updated to the data source in one step.
        ///  </para>
        /// </remarks>
        /// <returns>
        /// </returns>
        [OperationContract]
        void EnqueueNewOrUpdateEntities(CallContext cntx, RoleSet set, Role[] entities);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Queue a set of entities to be added or updated to the entity set in a certain preset future time. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">The current entity set.</param>
        /// <param name="entities">The list of entities to be processed.</param>
        /// <remarks>
        ///  <para>
        ///  The processing will be delayed to be started at a certain future time. If there are any further calls to this method during the wait period, the new sets will be 
        ///  merged with existing ones inside the queue. This method is useful when there are repetitive updates to the entity set but the actual change history is not of 
        ///  interest to the client, namely only the last snapshot of the changes are relevent. In this case, the method can reduce the loads on the backend data source 
        ///  significantly.
        ///  </para>
        ///  <para>
        ///  The list of entities will be checked against existing ones inside the entity set when the processing starts. An entity is identified by a set of "intrinsic identitfiers" selected
        ///  when the system is generated. They are not necessarily the same as primary keys of the set. An auto generated primary key can not be
        ///  used as an "intrinsic identitfier". An entity having the same set of "intrinsic identitfiers" can not be added to the database. They will be treated 
        ///  as an entity update if the client load the entity first before modifying it, otherwise (namely if the client created the entity on the client side), 
        ///  the update will be rejected unless the client set the <c>OverrideExisting</c> property  of "cntx" to <c>true</c>. 
        ///  </para>
        ///  <para>
        ///  Note: entities having no "intrinsic identitfier" will always be treated as different entities in add or update operations, namely they will always be added to the set.
        ///  </para>
        ///  <para>
        ///  Note 2: A persisted entity (namely the one loaded
        ///  from the data set) will be ignored in if none of its editable properties (set before system generation, see
        ///  <see cref="Role" />) is modified or its <see cref="Role.IsEntityChanged" /> property is
        ///  not set to <c>true</c>. 
        ///  </para>
        ///  <para>
        ///  Warning: Please do not use this method when new entities are to be added and information about these updated enitities, like auto generated primary keys, are needed for 
        ///  proceeding to the next steps.
        ///  </para>
        ///  <para>
        ///  Clients can set some of the member entities in { <see cref="Role.Application_Ref" />, <see cref="Role.UpperRef" /> } that an currently added or updated entity depends upon. These additional entities will be 
        ///  add or updated to the data source following the same logic, all the object relationships will be properly setup if the operation is successful.
        ///  </para>
        ///  <para>
        ///  Clients can also create and add to member collections in { <see cref="Role.ChangedRoles" />, <see cref="Role.ChangedUsersInRoles" /> } entities that depends on an currently added or updated entity. These 
        ///  additional entities will be add or updated to the data source following the same logic, all the object relationships will be properly setup if the operation is successful.
        ///  </para>
        ///  <para>
        ///  In general, a client can construct an object graph of any complexity following the above rules and have it added or updated to the data source in one step.
        ///  </para>
        /// </remarks>
        /// <returns>
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task EnqueueNewOrUpdateEntitiesAsync(CallContext cntx, RoleSet set, Role[] entities);
#endif

        /// <summary>
        ///  Delete a set of entities from the entity set, together with all their dependents, recursively. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">The current entity set.</param>
        /// <param name="entities">The list of entities to be processed.</param>
        /// <remarks>
        ///  <para>
        ///   Care should be taken when deleting an entire inter-dependent object sub-graph.
        ///  </para>
        /// </remarks>
        /// <returns>
        ///   Operation result contained inside an object of type <see cref="OperationResults" /> which contains operation messages, if any.
        /// </returns>
        [OperationContract]
        OperationResults DeleteEntities(CallContext cntx, RoleSet set, Role[] entities);
#if SUPPORT_ASYNC
        /// <summary>
        ///  Delete a set of entities from the entity set, together with all their dependents, recursively. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">The current entity set.</param>
        /// <param name="entities">The list of entities to be processed.</param>
        /// <remarks>
        ///  <para>
        ///   Care should be taken when deleting an entire inter-dependent object sub-graph.
        ///  </para>
        /// </remarks>
        /// <returns>
        ///   Operation result contained inside an object of type <see cref="OperationResults" /> which contains operation messages, if any.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<OperationResults> DeleteEntitiesAsync(CallContext cntx, RoleSet set, Role[] entities);
#endif

        /// <summary>
        ///   Count the number of entities inside entity set "Roles" of the data source under specified filtering condition. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   The number of entities.
        /// </returns>
        [OperationContract]
        Int64 QueryEntityCount(CallContext cntx, RoleSet set, QueryExpresion qexpr);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Count the number of entities inside entity set "Roles" of the data source under specified filtering condition. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   The number of entities.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<Int64> QueryEntityCountAsync(CallContext cntx, RoleSet set, QueryExpresion qexpr);
#endif

        /// <summary>
        ///   Get the collection of entities of type <see cref="Role" /> inside entity set "Roles" of the data source under specified filtering and sorting conditions. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   The collection of entities.
        /// </returns>
        [OperationContract]
        IEnumerable<Role> QueryDatabase(CallContext cntx, RoleSet set, QueryExpresion qexpr);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Get the collection of entities of type <see cref="Role" /> inside entity set "Roles" of the data source under specified filtering and sorting conditions. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   The collection of entities.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<IEnumerable<Role>> QueryDatabaseAsync(CallContext cntx, RoleSet set, QueryExpresion qexpr);
#endif

        /// <summary>
        ///   Get the collection of entities of type <see cref="Role" /> inside entity set "Roles" from the data source under specified filtering, sorting and max number of returning entities conditions. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <param name="maxRecords">Max number of entities to return.</param>
        /// <returns>
        ///   The collection of entities.
        /// </returns>
        [OperationContract]
        IEnumerable<Role> QueryDatabaseLimited(CallContext cntx, RoleSet set, QueryExpresion qexpr, int maxRecords);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Get the collection of entities of type <see cref="Role" /> inside entity set "Roles" from the data source under specified filtering, sorting and max number of returning entities conditions. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <param name="maxRecords">Max number of entities to return.</param>
        /// <returns>
        ///   The collection of entities.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<IEnumerable<Role>> QueryDatabaseLimitedAsync(CallContext cntx, RoleSet set, QueryExpresion qexpr, int maxRecords);
#endif

        /// <summary>
        ///   Get the number of entities from the data source restricted by a set of specified foreign key values and under specified filtering, sorting conditions. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="constraints">A set of foreign key wrapper pointing to primary keys of the sets that "Roles" depends upon. If a user do not wish to set a contraint for it, then set it to null, </param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   The number of entities.
        /// </returns>
        [OperationContract]
        Int64 ConstraintQueryEntityCount(CallContext cntx, RoleSet set, RoleSetConstraints constraints, QueryExpresion qexpr);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Get the number of entities from the data source restricted by a set of specified foreign key values and under specified filtering, sorting conditions. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="constraints">A set of foreign key wrapper pointing to primary keys of the sets that "Roles" depends upon. If a user do not wish to set a contraint for it, then set it to null, </param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   The number of entities.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<Int64> ConstraintQueryEntityCountAsync(CallContext cntx, RoleSet set, RoleSetConstraints constraints, QueryExpresion qexpr);
#endif

        /// <summary>
        ///   Given a set of foreign key constraints, find the ones that has non zero corresponding entities. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="cnstSets">A collection of sets of foreign key wrapper pointing to primary keys of the sets that "Roles" depends upon. If a user do not wish to set a contraint for it, then set it to null, </param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   A set of constraint pointer that has non-zero corresponding entities.
        /// </returns>
        [OperationContract]
        ConstraintsPtr[] ConstraintsFindMatches(CallContext cntx, RoleSet set, RoleSetConstraints[] cnstSets, QueryExpresion qexpr);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Given a set of foreign key constraints, find the ones that has non zero corresponding entities. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="cnstSets">A collection of sets of foreign key wrapper pointing to primary keys of the sets that "Roles" depends upon. If a user do not wish to set a contraint for it, then set it to null, </param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   A set of constraint pointer that has non-zero corresponding entities.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<ConstraintsPtr[]> ConstraintsFindMatchesAsync(CallContext cntx, RoleSet set, RoleSetConstraints[] cnstSets, QueryExpresion qexpr);
#endif

        /// <summary>
        ///   Get the collection of entities of type <see cref="Role" /> inside entity set "Roles" from the data source restricted by a set of specified foreign key values and under specified filtering, sorting conditions. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="constraints">A set of foreign key wrapper pointing to primary keys of the sets that "Roles" depends upon. If a user do not wish to set a contraint for it, then set it to null, </param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   The collection of entities.
        /// </returns>
        [OperationContract]
        IEnumerable<Role> ConstraintQuery(CallContext cntx, RoleSet set, RoleSetConstraints constraints, QueryExpresion qexpr);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Get the collection of entities of type <see cref="Role" /> inside entity set "Roles" from the data source restricted by a set of specified foreign key values and under specified filtering, sorting conditions. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="constraints">A set of foreign key wrapper pointing to primary keys of the sets that "Roles" depends upon. If a user do not wish to set a contraint for it, then set it to null, </param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <returns>
        ///   The collection of entities.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<IEnumerable<Role>> ConstraintQueryAsync(CallContext cntx, RoleSet set, RoleSetConstraints constraints, QueryExpresion qexpr);
#endif

        /// <summary>
        ///   Get the collection of entities of type <see cref="Role" /> inside entity set "Roles" of the data source restricted by a set of specified foreign key values and under specified filtering, sorting and max number of returning entities conditions. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="constraints">A set of foreign key wrapper pointing to primary keys of the sets that "Roles" depends upon. If a user do not wish to set a contraint for it, then set it to null, </param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <param name="maxRecords">Max number of entities to return.</param>
        /// <returns>
        ///   The collection of entities.
        /// </returns>
        [OperationContract]
        IEnumerable<Role> ConstraintQueryLimited(CallContext cntx, RoleSet set, RoleSetConstraints constraints, QueryExpresion qexpr, int maxRecords);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Get the collection of entities of type <see cref="Role" /> inside entity set "Roles" of the data source restricted by a set of specified foreign key values and under specified filtering, sorting and max number of returning entities conditions. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="constraints">A set of foreign key wrapper pointing to primary keys of the sets that "Roles" depends upon. If a user do not wish to set a contraint for it, then set it to null, </param>
        /// <param name="qexpr">Tokenized querying and sorting expression.</param>
        /// <param name="maxRecords">Max number of entities to return.</param>
        /// <returns>
        ///   The collection of entities.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<IEnumerable<Role>> ConstraintQueryLimitedAsync(CallContext cntx, RoleSet set, RoleSetConstraints constraints, QueryExpresion qexpr, int maxRecords);
#endif

        /// <summary>
        ///   Load the entity "Application_Ref" of type <see cref="Application_" /> that the entity depend upon. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <remarks>
        /// If the corresponding foreign key is nullable, the returned entity can be null.
        /// </remarks>
        /// <returns>
        ///   An entity of type <see cref="Application_" /> or null.
        /// </returns>
        [OperationContract]
        Application_ MaterializeApplication_Ref(CallContext cntx, Role entity);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Load the entity "Application_Ref" of type <see cref="Application_" /> that the entity depend upon. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <remarks>
        /// If the corresponding foreign key is nullable, the returned entity can be null.
        /// </remarks>
        /// <returns>
        ///   An entity of type <see cref="Application_" /> or null.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<Application_> MaterializeApplication_RefAsync(CallContext cntx, Role entity);
#endif

        /// <summary>
        ///   Load the entity "UpperRef" of type <see cref="Role" /> that the entity depend upon. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <remarks>
        /// If the corresponding foreign key is nullable, the returned entity can be null.
        /// </remarks>
        /// <returns>
        ///   An entity of type <see cref="Role" /> or null.
        /// </returns>
        [OperationContract]
        Role MaterializeUpperRef(CallContext cntx, Role entity);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Load the entity "UpperRef" of type <see cref="Role" /> that the entity depend upon. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <remarks>
        /// If the corresponding foreign key is nullable, the returned entity can be null.
        /// </remarks>
        /// <returns>
        ///   An entity of type <see cref="Role" /> or null.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<Role> MaterializeUpperRefAsync(CallContext cntx, Role entity);
#endif

        /// <summary>
        ///   Get the collection of non-trivial foreign key constrains of type <see cref="Role" /> inside entity set "Roles" of the data source under specified filtering and sorting conditions. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Filter expression for the set.</param>
        /// <param name="max">Number of items per page.</param>
        /// <param name="nextId">The id of next page, if any.</param>
        /// <returns>
        ///   The collection of independent non-trivial foreign key constrains.
        /// </returns>
        /// <remarks>It will throw an exception if the <see cref="RoleSet.SetFilter" /> of <paramref name="set" /> is null or empty.</remarks>
        [OperationContract]
        RoleSetConstraintsColl QuerySetConstraints(CallContext cntx, RoleSet set, QueryExpresion qexpr, int max, string nextId);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Get the collection of non-trivial foreign key constrains of type <see cref="Role" /> inside entity set "Roles" of the data source under specified filtering and sorting conditions. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="set">Set information.</param>
        /// <param name="qexpr">Filter expression for the set.</param>
        /// <param name="max">Number of items per page.</param>
        /// <param name="nextId">The id of next page, if any.</param>
        /// <returns>
        ///   The collection of independent non-trivial foreign key constrains.
        /// </returns>
        /// <remarks>It will throw an exception if the <see cref="RoleSet.SetFilter" /> of <paramref name="set" /> is null or empty.</remarks>
        [OperationContract]
        System.Threading.Tasks.Task<RoleSetConstraintsColl> QuerySetConstraintsAsync(CallContext cntx, RoleSet set, QueryExpresion qexpr, int max, string nextId);
#endif

        /// <summary>
        ///   Load the set of depending entities "Roles" of type <see cref="RoleSet" /> of the entity. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <remarks>
        ///  The set returned is a filtered subset whose members are all depending on the entity.
        /// </remarks>
        /// <returns>
        ///   An entity of type <see cref="RoleSet" />.
        /// </returns>
        [OperationContract]
        RoleSet MaterializeRoles(CallContext cntx, Role entity);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Load the set of depending entities "Roles" of type <see cref="RoleSet" /> of the entity. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <remarks>
        ///  The set returned is a filtered subset whose members are all depending on the entity.
        /// </remarks>
        /// <returns>
        ///   An entity of type <see cref="RoleSet" />.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<RoleSet> MaterializeRolesAsync(CallContext cntx, Role entity);
#endif

        /// <summary>
        ///   Load the collection of depending entities "AllRoles" of type <see cref="IEnumerable{Role}" /> (T = <see cref="Role" />) of the entity. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <returns>
        ///   An collecton of type <see cref="IEnumerable{Role}" /> (T = <see cref="Role" />).
        /// </returns>
        [OperationContract]
        IEnumerable<Role> MaterializeAllRoles(CallContext cntx, Role entity);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Load the collection of depending entities "AllRoles" of type <see cref="IEnumerable{Role}" /> (T = <see cref="Role" />) of the entity. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <returns>
        ///   An collecton of type <see cref="IEnumerable{Role}" /> (T = <see cref="Role" />).
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<IEnumerable<Role>> MaterializeAllRolesAsync(CallContext cntx, Role entity);
#endif

        /// <summary>
        ///   Load the set of depending entities "UsersInRoles" of type <see cref="UsersInRoleSet" /> of the entity. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <remarks>
        ///  The set returned is a filtered subset whose members are all depending on the entity.
        /// </remarks>
        /// <returns>
        ///   An entity of type <see cref="UsersInRoleSet" />.
        /// </returns>
        [OperationContract]
        UsersInRoleSet MaterializeUsersInRoles(CallContext cntx, Role entity);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Load the set of depending entities "UsersInRoles" of type <see cref="UsersInRoleSet" /> of the entity. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <remarks>
        ///  The set returned is a filtered subset whose members are all depending on the entity.
        /// </remarks>
        /// <returns>
        ///   An entity of type <see cref="UsersInRoleSet" />.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<UsersInRoleSet> MaterializeUsersInRolesAsync(CallContext cntx, Role entity);
#endif

        /// <summary>
        ///   Load the collection of depending entities "AllUsersInRoles" of type <see cref="IEnumerable{UsersInRole}" /> (T = <see cref="UsersInRole" />) of the entity. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <returns>
        ///   An collecton of type <see cref="IEnumerable{UsersInRole}" /> (T = <see cref="UsersInRole" />).
        /// </returns>
        [OperationContract]
        IEnumerable<UsersInRole> MaterializeAllUsersInRoles(CallContext cntx, Role entity);
#if SUPPORT_ASYNC
        /// <summary>
        ///   Load the collection of depending entities "AllUsersInRoles" of type <see cref="IEnumerable{UsersInRole}" /> (T = <see cref="UsersInRole" />) of the entity. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The entity.</param>
        /// <returns>
        ///   An collecton of type <see cref="IEnumerable{UsersInRole}" /> (T = <see cref="UsersInRole" />).
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<IEnumerable<UsersInRole>> MaterializeAllUsersInRolesAsync(CallContext cntx, Role entity);
#endif

        /// <summary>
        ///  Load an entity from the entity set having specified primary key(s): { <see cref="Role.ID" /> }. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_ID">Primary key <see cref="Role.ID" />.</param>
        /// <returns>
        ///   Null or the entity found.
        /// </returns>
        [OperationContract]
        Role LoadEntityByKey(CallContext cntx, int _ID);
#if SUPPORT_ASYNC
        /// <summary>
        ///  Load an entity from the entity set having specified primary key(s): { <see cref="Role.ID" /> }. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_ID">Primary key <see cref="Role.ID" />.</param>
        /// <returns>
        ///   Null or the entity found.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<Role> LoadEntityByKeyAsync(CallContext cntx, int _ID);
#endif

        /// <summary>
        ///  Load a selected entity graph from the data source starting at an entity having specified primary key(s): { <see cref="Role.ID" /> }. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_ID">Primary key <see cref="Role.ID" />.</param>
        /// <param name="excludedSets">A list of sets to be excluded. </param>
        /// <param name="futherDrillSets">A list of sets above the entry set that are to be drilled down futher (see the following). </param>
        /// <remarks>
        /// <para>Relational databases are designed to serve as data query and storage backend, in a normalized way, for certain kind of applications. 
        /// However at the application level, normalized elementary data sets are often combined (jointed) in a user friendly way as views. In the object oriented 
        /// world and at the data view model level, these views can be represented using entity graphs.</para>
        /// <para>This method is designed to load a selected sub entity graph recursively starting from a given entity (id) from the data source in one call 
        /// to the service, which could be used to increase performance and to reduce client code complexity, sometimes significantly.</para>
        /// <para>The selection is controlled by the two parameters, namely <paramref name="excludedSets" /> and <paramref name="futherDrillSets" />.</para>
        /// <para>The <paramref name="excludedSets" /> parameter is used to exclude a list of entity sets and all other sets that depend on it. This can be
        /// better understood if one has a look at the schematic view of the data set schema that is shown on the front page of the data service, namely
        /// if one date set (node) is excluded then all the sets that it points to will not be reached through it, although some of them could still be reached
        /// following other routes. </para>
        /// <para>There are many ways an entity sub-graph can be loaded, the present implementation is based on the rule to be given next. Namely, starting from 
        /// entry element, it loads all entities that depends on it, recursively downward (namely following the arrows in the schema view). It also load all 
        /// elements that any of the elements visited by the downward recursion depends upon, recursively upward (namely in 
        /// the opposite direction of the arrows in the schema view), but never go downward again without explicit instruction.</para>
        /// <para>The <paramref name="futherDrillSets" /> parameter is used control when to go downward again, represented by the <see cref="EntitySetRelation.SetType" /> member 
        /// and the collection of data sets that depend on it, represented by the <see cref="EntitySetRelation.RelatedSets" /> member, should be further drilled down, recursively.</para>
        /// <para>Note that a data service has intrinsic limits that does not allow transimitting an entity graph that is too large in one call, so one has to select which part
        /// of the entire graph should be loaded in each call to the data service,</para>
        /// <para>For a given entity, the entities that it depends upon are represented by the member objects corresponding to each foreign keys. However, the
        /// sets of entities that depend on the said entity are stored into the corresponding collection members having the "Changed" prefix and
        /// these entities do not have a back reference to the said entity to avoid circular references when doing serialization, Such back references can be
        /// added after the graph is materialized on the clients side, if needed.</para>
        /// </remarks>
        /// <returns>
        ///   Null or the entity graph found.
        /// </returns>
        [OperationContract]
        Role LoadEntityGraphRecurs(CallContext cntx, int _ID, EntitySetType[] excludedSets, EntitySetRelation[] futherDrillSets);
#if SUPPORT_ASYNC
        /// <summary>
        ///  Load a selected entity graph from the data source starting at an entity having specified primary key(s): { <see cref="Role.ID" /> }. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_ID">Primary key <see cref="Role.ID" />.</param>
        /// <param name="excludedSets">A list of sets to be excluded. </param>
        /// <param name="futherDrillSets">A list of sets above the entry set that are to be drilled down futher (see the following). </param>
        /// <remarks>
        /// <para>Relational databases are designed to serve as data query and storage backend, in a normalized way, for certain kind of applications. 
        /// However at the application level, normalized elementary data sets are often combined (jointed) in a user friendly way as views. In the object oriented 
        /// world and at the data view model level, these views can be represented using entity graphs.</para>
        /// <para>This method is designed to load a selected sub entity graph recursively starting from a given entity (id) from the data source in one call 
        /// to the service, which could be used to increase performance and to reduce client code complexity, sometimes significantly.</para>
        /// <para>The selection is controlled by the two parameters, namely <paramref name="excludedSets" /> and <paramref name="futherDrillSets" />.</para>
        /// <para>The <paramref name="excludedSets" /> parameter is used to exclude a list of entity sets and all other sets that depend on it. This can be
        /// better understood if one has a look at the schematic view of the data set schema that is shown on the front page of the data service, namely
        /// if one date set (node) is excluded then all the sets that it points to will not be reached through it, although some of them could still be reached
        /// following other routes. </para>
        /// <para>There are many ways an entity sub-graph can be loaded, the present implementation is based on the rule to be given next. Namely, starting from 
        /// entry element, it loads all entities that depends on it, recursively downward (namely following the arrows in the schema view). It also load all 
        /// elements that any of the elements visited by the downward recursion depends upon, recursively upward (namely in 
        /// the opposite direction of the arrows in the schema view), but never go downward again without explicit instruction.</para>
        /// <para>The <paramref name="futherDrillSets" /> parameter is used control when to go downward again, represented by the <see cref="EntitySetRelation.SetType" /> member 
        /// and the collection of data sets that depend on it, represented by the <see cref="EntitySetRelation.RelatedSets" /> member, should be further drilled down, recursively.</para>
        /// <para>Note that a data service has intrinsic limits that does not allow transimitting an entity graph that is too large in one call, so one has to select which part
        /// of the entire graph should be loaded in each call to the data service,</para>
        /// <para>For a given entity, the entities that it depends upon are represented by the member objects corresponding to each foreign keys. However, the
        /// sets of entities that depend on the said entity are stored into the corresponding collection members having the "Changed" prefix and
        /// these entities do not have a back reference to the said entity to avoid circular references when doing serialization, Such back references can be
        /// added after the graph is materialized on the clients side, if needed.</para>
        /// </remarks>
        /// <returns>
        ///   Null or the entity graph found.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<Role> LoadEntityGraphRecursAsync(CallContext cntx, int _ID, EntitySetType[] excludedSets, EntitySetRelation[] futherDrillSets);
#endif

        /// <summary>
        ///  Load a set entities from the entity set having specified intrinsic ids: { <see cref="Role.RoleName" />, <see cref="Role.ApplicationID" />, <see cref="Role.ParentID" /> }. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_RoleName">Intrinsic id <see cref="Role.RoleName" />.</param>
        /// <param name="_ApplicationID">Intrinsic id <see cref="Role.ApplicationID" />.</param>
        /// <param name="_ParentID">Intrinsic id <see cref="Role.ParentID" />.</param>
        /// <remarks>
        ///  <para>
        ///   If the intrinsic identifiers are well chosen, the returned entity set should contain zero or one item. This could not be the case
        ///   if the system is attached to an existing database whose data were entered without respecting the rules (namely those entities having the
        ///   same set of intrinsic identifiers should appear only once inside the data source) imposed later by the
        ///   system.
        ///  </para>
        /// </remarks>
        /// <returns>
        ///   The list of found entities.
        /// </returns>
        [OperationContract]
        List<Role> LoadEntityByNature(CallContext cntx, string _RoleName, string _ApplicationID, System.Nullable<int> _ParentID);
#if SUPPORT_ASYNC
        /// <summary>
        ///  Load a set entities from the entity set having specified intrinsic ids: { <see cref="Role.RoleName" />, <see cref="Role.ApplicationID" />, <see cref="Role.ParentID" /> }. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_RoleName">Intrinsic id <see cref="Role.RoleName" />.</param>
        /// <param name="_ApplicationID">Intrinsic id <see cref="Role.ApplicationID" />.</param>
        /// <param name="_ParentID">Intrinsic id <see cref="Role.ParentID" />.</param>
        /// <remarks>
        ///  <para>
        ///   If the intrinsic identifiers are well chosen, the returned entity set should contain zero or one item. This could not be the case
        ///   if the system is attached to an existing database whose data were entered without respecting the rules (namely those entities having the
        ///   same set of intrinsic identifiers should appear only once inside the data source) imposed later by the
        ///   system.
        ///  </para>
        /// </remarks>
        /// <returns>
        ///   The list of found entities.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<List<Role>> LoadEntityByNatureAsync(CallContext cntx, string _RoleName, string _ApplicationID, System.Nullable<int> _ParentID);
#endif

        /// <summary>
        ///  For a hierarchic data set, load a set root entities from the entity set. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <remarks>
        ///  A root entity is one that have no dependency on other entities inside the same data set, or its foreign key <see cref="Role.ParentID" /> = null.
        /// </remarks>
        /// <returns>
        ///   A set of wrapped root entities.
        /// </returns>
        [OperationContract]
        IEnumerable<EntityAbs<Role>> LoadEntitySetRoots(CallContext cntx);
#if SUPPORT_ASYNC
        /// <summary>
        ///  For a hierarchic data set, load a set root entities from the entity set. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <remarks>
        ///  A root entity is one that have no dependency on other entities inside the same data set, or its foreign key <see cref="Role.ParentID" /> = null.
        /// </remarks>
        /// <returns>
        ///   A set of wrapped root entities.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<IEnumerable<EntityAbs<Role>>> LoadEntitySetRootsAsync(CallContext cntx);
#endif

        /// <summary>
        ///  For a hierarchic data set, load a wrapped parent node of a node from the entity set. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="node">The wrapped node under consideration.</param>
        /// <remarks>
        /// </remarks>
        /// <returns>
        ///   Null or a wrapped parent entity.
        /// </returns>
        [OperationContract]
        EntityAbs<Role> LoadEntityParent(CallContext cntx, EntityAbs<Role> node);
#if SUPPORT_ASYNC
        /// <summary>
        ///  For a hierarchic data set, load a wrapped parent node of a node from the entity set. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="node">The wrapped node under consideration.</param>
        /// <remarks>
        /// </remarks>
        /// <returns>
        ///   Null or a wrapped parent entity.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<EntityAbs<Role>> LoadEntityParentAsync(CallContext cntx, EntityAbs<Role> node);
#endif

        /// <summary>
        ///  For a hierarchic data set, load a collection of wrapped child nodes of a node from the entity set. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="node">The wrapped node under consideration.</param>
        /// <remarks>
        /// </remarks>
        /// <returns>
        ///   A collection of wrapped child entities.
        /// </returns>
        [OperationContract]
        IEnumerable<EntityAbs<Role>> LoadEntityChildren(CallContext cntx, EntityAbs<Role> node);
#if SUPPORT_ASYNC
        /// <summary>
        ///  For a hierarchic data set, load a collection of wrapped child nodes of a node from the entity set. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="node">The wrapped node under consideration.</param>
        /// <remarks>
        /// </remarks>
        /// <returns>
        ///   A collection of wrapped child entities.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<IEnumerable<EntityAbs<Role>>> LoadEntityChildrenAsync(CallContext cntx, EntityAbs<Role> node);
#endif

        /// <summary>
        ///  For a hierarchic data set, load the entire tree of wrapped nodes from the entity set, starting from any member node. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The starting entity under consideration.</param>
        /// <remarks>
        ///  Loading a tree in one call to the database can increase the performance by reducing the number of calls to the data service.
        /// </remarks>
        /// <returns>
        ///   The wrapped root entity of the tree.
        /// </returns>
        [OperationContract]
        EntityAbs<Role> LoadEntityFullHierarchyRecurs(CallContext cntx, Role entity);
#if SUPPORT_ASYNC
        /// <summary>
        ///  For a hierarchic data set, load the entire tree of wrapped nodes from the entity set, starting from any member node. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The starting entity under consideration.</param>
        /// <remarks>
        ///  Loading a tree in one call to the database can increase the performance by reducing the number of calls to the data service.
        /// </remarks>
        /// <returns>
        ///   The wrapped root entity of the tree.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<EntityAbs<Role>> LoadEntityFullHierarchyRecursAsync(CallContext cntx, Role entity);
#endif

        /// <summary>
        ///   For a hierarchic data set, load a sub-tree of wrapped nodes with maximum relative height and relative depth from the entity set starting from any member node. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The starting entity under consideration.</param>
        /// <param name="uplev">Include parent nodes of the starting node, together with all the sibling trees under them, up to this value in relative height. If the value is -1, then all 
        ///    of the parent nodes and sibling trees (if any) will be included,</param>
        /// <param name="lowlev">Include child nodes of the starting node down to this value in relative depth. If the value is -1, then all of the child nodes will be included,</param>
        /// <remarks>
        /// For a large tree, this method can help the clients to load only a partial tree with limited hight and depth that is connected to the starting node.
        /// Loading a partial tree in one call to the database can increase the performance by reducing the number of calls to the data service.
        /// </remarks>
        /// <returns>
        ///   The wrapped root entity of the partial tree.
        /// </returns>
        [OperationContract]
        EntityAbs<Role> LoadEntityHierarchyRecurs(CallContext cntx, Role entity, int uplev, int lowlev);
#if SUPPORT_ASYNC
        /// <summary>
        ///   For a hierarchic data set, load a sub-tree of wrapped nodes with maximum relative height and relative depth from the entity set starting from any member node. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="entity">The starting entity under consideration.</param>
        /// <param name="uplev">Include parent nodes of the starting node, together with all the sibling trees under them, up to this value in relative height. If the value is -1, then all 
        ///    of the parent nodes and sibling trees (if any) will be included,</param>
        /// <param name="lowlev">Include child nodes of the starting node down to this value in relative depth. If the value is -1, then all of the child nodes will be included,</param>
        /// <remarks>
        /// For a large tree, this method can help the clients to load only a partial tree with limited hight and depth that is connected to the starting node.
        /// Loading a partial tree in one call to the database can increase the performance by reducing the number of calls to the data service.
        /// </remarks>
        /// <returns>
        ///   The wrapped root entity of the partial tree.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<EntityAbs<Role>> LoadEntityHierarchyRecursAsync(CallContext cntx, Role entity, int uplev, int lowlev);
#endif

        /// <summary>
        ///  Load the delay loaded property <see cref="Role.Description" />. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_ID">Primary key <see cref="Role.ID" />.</param>
        /// <remarks>
        /// </remarks>
        /// <returns>
        ///   The value of the property.
        /// </returns>
        [OperationContract]
        string LoadEntityDescription(CallContext cntx, int _ID);
#if SUPPORT_ASYNC
        /// <summary>
        ///  Load the delay loaded property <see cref="Role.Description" />. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_ID">Primary key <see cref="Role.ID" />.</param>
        /// <remarks>
        /// </remarks>
        /// <returns>
        ///   The value of the property.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<string> LoadEntityDescriptionAsync(CallContext cntx, int _ID);
#endif

        /// <summary>
        ///  Update the delay loaded property <see cref="Role.Description" />. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_ID">Primary key <see cref="Role.ID" />.</param>
        /// <param name="data">The updated value.</param>
        /// <remarks>
        /// </remarks>
        /// <returns>
        ///   The value of the property.
        /// </returns>
        [OperationContract]
        void UpdateEntityDescription(CallContext cntx, int _ID, string data);
#if SUPPORT_ASYNC
        /// <summary>
        ///  Update the delay loaded property <see cref="Role.Description" />. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="_ID">Primary key <see cref="Role.ID" />.</param>
        /// <param name="data">The updated value.</param>
        /// <remarks>
        /// </remarks>
        /// <returns>
        ///   The value of the property.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task UpdateEntityDescriptionAsync(CallContext cntx, int _ID, string data);
#endif

        /// <summary>
        ///  Given the current sorter expression <paramref name="sorters" />, it returns the next sorter token options. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="sorters">Sorter expression tokens.</param>
        /// <returns>
        ///   A list of possible sort tokens.
        /// </returns>
        [OperationContract]
        TokenOptions GetNextSorterOps(CallContext cntx, List<QToken> sorters);
#if SUPPORT_ASYNC
        /// <summary>
        ///  Given the current sorter expression <paramref name="sorters" />, it returns the next sorter token options. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="sorters">Sorter expression tokens.</param>
        /// <returns>
        ///   A list of possible sort tokens.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<TokenOptions> GetNextSorterOpsAsync(CallContext cntx, List<QToken> sorters);
#endif

        /// <summary>
        ///  Given the current query expression <paramref name="qexpr" />, it returns the next filter token options. 
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="qexpr">The current query expression.</param>
        /// <param name="tkstr">Partial user input to filter the options further. It is not used on the service side in the current version of the system.</param>
        /// <returns>
        ///   A list of possible filter tokens.
        /// </returns>
        [OperationContract]
        TokenOptions GetNextFilterOps(CallContext cntx, QueryExpresion qexpr, string tkstr);
#if SUPPORT_ASYNC
        /// <summary>
        ///  Given the current query expression <paramref name="qexpr" />, it returns the next filter token options. Awaitable asynchronous version.
        /// </summary>
        /// <param name="cntx">Authenticated caller context object. If cannot be null.</param>
        /// <param name="qexpr">The current query expression.</param>
        /// <param name="tkstr">Partial user input to filter the options further. It is not used on the service side in the current version of the system.</param>
        /// <returns>
        ///   A list of possible filter tokens.
        /// </returns>
        [OperationContract]
        System.Threading.Tasks.Task<TokenOptions> GetNextFilterOpsAsync(CallContext cntx, QueryExpresion qexpr, string tkstr);
#endif

    }

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder CryptoGateway Software Inc.
Canada Canada


His interests in software research and development include security, domain specific meta-language development technologies and tools, meta-language driven code generation, generation of non-invasive and virtual SQL database for "un-structured" data (sqlization), automated relational data service production technologies, file system sqlization technologies and products, structured multi-lingual documentation tools and technologies, sqlization of user's personal data, like emails, etc..


He was a physicist before year 2000. He studied theoretical physics (the hidden symmetry between the past and future, quantum field theories, mirror universe, cosmological dark energies etc.) in which he think to had made fundamental breakthroughs[^] but the community is either not ready for it or is actively rejecting/ignoring it Smile | :) .



It struck me on Apr. 11, 2023 that the said theory above can even generate General Relativity naturally after a recent discussion in the Insider News group that triggers a rethinking of the subject on my side. The first stage of the work is completed in Sept. 2023, it is and will be continue to be published online

  • On Vacuum
  • Quantum and Gravity







    Most recent software system to share:



    • V-NET[^] - Full stack virtualization management system including networking, storage, virtual machines and containers, with an emphasis on networking ... to be released.

Comments and Discussions