internal Guid CreateActivityParty(Entity entity) { if (entity.GetType() == typeof(Entity)) { entity = GenericMethodCaller.InvokeToEntity(entity, Info); } return((Guid)GenericMethodCaller.InvokeLocalCrmDatabaseStaticGenericMethod(Info, entity.LogicalName, "Create", this, entity)); }
public void Update(Entity entity) { AssertValidForOperation(entity, "Update"); if (entity.GetType() == typeof(Entity)) { entity = GenericMethodCaller.InvokeToEntity(entity, Info); } GenericMethodCaller.InvokeLocalCrmDatabaseStaticGenericMethod(Info, entity.LogicalName, "Update", this, entity); }
public Guid Create(Entity entity) { AssertValidForOperation(entity, nameof(Create)); if (entity.GetType() == typeof(Entity)) { entity = GenericMethodCaller.InvokeToEntity(entity, Info); } return((Guid)GenericMethodCaller.InvokeLocalCrmDatabaseStaticGenericMethod(Info, entity.LogicalName, nameof(Create), this, entity)); }
private EntityCollection RetrieveMultipleInternal(FetchExpression fetchExpression) { var s = new XmlSerializer(typeof(FetchType)); FetchType fetch; using (var r = new StringReader(fetchExpression.Query)) { fetch = (FetchType)s.Deserialize(r); r.Close(); } return((EntityCollection)GenericMethodCaller.InvokeLocalCrmDatabaseStaticGenericMethod(Info, ((FetchEntityType)fetch.Items[0]).name, "ReadFetchXmlEntities", this, fetch)); }
private static IQueryable <TRoot> CallChildJoin <TRoot, TFrom>(LocalCrmDatabaseInfo info, IQueryable <TRoot> query, LinkEntity fromEntity, LinkEntity link) where TRoot : Entity where TFrom : Entity { var tRoot = typeof(TRoot); var tTo = GetType(info, link.LinkToEntityName); return((IQueryable <TRoot>)GenericMethodCaller.InvokeLocalCrmDatabaseStaticMultiGenericMethod( info, nameof(ChildJoin), BindingFlags.NonPublic, new object[] { tRoot, typeof(TFrom), tTo }, info, query, fromEntity, link)); }
/// <summary> /// CRM will convert non typed arrays into an IEnumerable<T>. Handle that conversion here /// </summary> /// <typeparam name="T"></typeparam> /// <param name="entity">The entity.</param> /// <param name="key">The key.</param> /// <param name="properties">The properties.</param> private static void ConvertEntityArrayToEntityCollection <T>(T entity, string key, Dictionary <string, List <PropertyInfo> > properties) where T : Entity { if (!(entity[key] is Array value) || value.Length == 0) { return; } var prop = properties[key].FirstOrDefault(p => p.PropertyType.GetGenericArguments().Length >= 0); var genericArgs = prop?.PropertyType.GetGenericArguments()[0]; // ReSharper disable once SuspiciousTypeConversion.Global if (genericArgs != null && value is IEnumerable <Entity> entityEnumerable && IsSameOrSubclass(typeof(Entity), genericArgs)) { var entities = new EntityCollection(); foreach (var att in entityEnumerable) { entities.Entities.Add(GenericMethodCaller.InvokeToEntity(att, genericArgs)); } entity[key] = entities; } }
private static IQueryable <T> CallJoin <T>(LocalCrmDatabaseInfo info, IQueryable <T> query, LinkEntity link) where T : Entity { try { var tFrom = typeof(T); var tTo = GetType(info, link.LinkToEntityName); return((IQueryable <T>)GenericMethodCaller.InvokeLocalCrmDatabaseStaticMultiGenericMethod( info, nameof(Join), BindingFlags.NonPublic, new object[] { tFrom, tTo }, info, query, link)); } catch (TargetInvocationException ex) { if (ex.InnerException == null) { throw; } throw ex.InnerException; } }
private EntityCollection RetrieveMultipleInternal(QueryByAttribute query) { return((EntityCollection)GenericMethodCaller.InvokeLocalCrmDatabaseStaticGenericMethod(Info, query.EntityName, "ReadEntitiesByAttribute", this, query)); }
private EntityCollection RetrieveMultipleInternal(QueryExpression qe) { return((EntityCollection)GenericMethodCaller.InvokeLocalCrmDatabaseStaticGenericMethod(Info, qe.EntityName, "ReadEntities", this, qe)); }
public Entity Retrieve(string entityName, Guid id, ColumnSet columnSet) { return((Entity)GenericMethodCaller.InvokeLocalCrmDatabaseStaticGenericMethod(Info, entityName, "Read", this, id, columnSet)); }
public void Delete(string entityName, Guid id) { AssertValidForOperation(entityName, nameof(Delete)); GenericMethodCaller.InvokeLocalCrmDatabaseStaticGenericMethod(Info, entityName, nameof(Delete), this, id); }
private static Entity GetDatabaseEntity(LocalCrmDatabaseInfo info, string logicalName, Guid id) { return((Entity)GenericMethodCaller.InvokeLocalCrmDatabaseStaticGenericMethod(info, logicalName, nameof(GetDatabaseEntity), BindingFlags.NonPublic | BindingFlags.Static, info, id)); }
private AssignResponse ExecuteInternal(AssignRequest request) { GenericMethodCaller.InvokeLocalCrmDatabaseStaticGenericMethod(Info, request.Target.LogicalName, "Assign", this, request.Target, request.Assignee); return(new AssignResponse()); }