Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion XrmOrg/XrmOrg.XrmSolution/BusinessDomain/XrmContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// </auto-generated>
//------------------------------------------------------------------------------

using DG.XrmContext;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using System;
Expand Down
45 changes: 23 additions & 22 deletions XrmOrg/XrmOrg.XrmSolution/BusinessDomain/XrmExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Messages;

namespace DG.XrmContext
namespace DG.XrmFramework.BusinessDomain.ServiceContext
{

public enum EmptyEnum { }

public abstract partial class ExtendedEntity<State, Status> : Entity
public abstract partial class ExtendedEntity<State, Status> : Microsoft.Xrm.Sdk.Entity
where State : struct, IComparable, IConvertible, IFormattable
where Status : struct, IComparable, IConvertible, IFormattable
{
Expand Down Expand Up @@ -115,24 +115,24 @@ protected void SetMoneyValue(string attributeName, decimal? value)
}
}

protected IEnumerable<T> GetEntityCollection<T>(string attributeName) where T : Entity
protected IEnumerable<T> GetEntityCollection<T>(string attributeName) where T : Microsoft.Xrm.Sdk.Entity
{
var collection = GetAttributeValue<EntityCollection>(attributeName);
if (collection != null && collection.Entities != null)
{
return collection.Entities.Select(x => x as T);
return collection.Entities.Select(x => x.ToEntity<T>());
}
else
{
return null;
}
}

protected void SetEntityCollection<T>(string attributeName, IEnumerable<T> entities) where T : Entity
protected void SetEntityCollection<T>(string attributeName, IEnumerable<T> entities) where T : Microsoft.Xrm.Sdk.Entity
{
if (entities != null)
{
SetAttributeValue(attributeName, new EntityCollection(new List<Entity>(entities)));
SetAttributeValue(attributeName, new EntityCollection(new List<Microsoft.Xrm.Sdk.Entity>(entities)));
}
else
{
Expand All @@ -146,7 +146,6 @@ protected void SetId(string primaryIdAttribute, Guid? guid)
SetAttributeValue(primaryIdAttribute, guid);
}


protected KeyValuePair<string, object>[] DeltaAttributes;

public void TagForDelta()
Expand All @@ -168,8 +167,7 @@ public void PerformDelta()
if (guid != Guid.Empty) Id = guid;
}


protected static T Retrieve_AltKey<T>(IOrganizationService service, KeyAttributeCollection keys, params Expression<Func<T, object>>[] attributes) where T : Entity
protected static T Retrieve_AltKey<T>(IOrganizationService service, KeyAttributeCollection keys, params Expression<Func<T, object>>[] attributes) where T : Microsoft.Xrm.Sdk.Entity
{
var req = new RetrieveRequest();
req.Target = new EntityReference(Activator.CreateInstance<T>().LogicalName, keys);
Expand All @@ -183,7 +181,8 @@ protected static T Retrieve_AltKey<T>(IOrganizationService service, KeyAttribute
return null;
}
}
public static string GetColumnName<T>(Expression<Func<T, object>> lambda) where T : Entity

public static string GetColumnName<T>(Expression<Func<T, object>> lambda) where T : Microsoft.Xrm.Sdk.Entity
{
MemberExpression body = lambda.Body as MemberExpression;

Expand All @@ -206,7 +205,7 @@ public static string GetColumnName<T>(Expression<Func<T, object>> lambda) where
return body.Member.Name;
}

public static T Retrieve<T>(IOrganizationService service, Guid id, params Expression<Func<T, object>>[] attributes) where T : Entity
public static T Retrieve<T>(IOrganizationService service, Guid id, params Expression<Func<T, object>>[] attributes) where T : Microsoft.Xrm.Sdk.Entity
{
return service.Retrieve(id, attributes);
}
Expand Down Expand Up @@ -245,7 +244,7 @@ public interface IEntity
string RowVersion { get; set; }
bool Contains(string attributeName);
T GetAttributeValue<T>(string attributeLogicalName);
T ToEntity<T>() where T : Entity;
T ToEntity<T>() where T : Microsoft.Xrm.Sdk.Entity;
EntityReference ToEntityReference();
KeyAttributeCollection KeyAttributes { get; set; }
}
Expand All @@ -255,13 +254,13 @@ public abstract partial class ExtendedOrganizationServiceContext : OrganizationS

public ExtendedOrganizationServiceContext(IOrganizationService service) : base(service) { }

public U Load<T, U>(T entity, Expression<Func<T, U>> loaderFunc) where T : Entity
public U Load<T, U>(T entity, Expression<Func<T, U>> loaderFunc) where T : Microsoft.Xrm.Sdk.Entity
{
LoadProperty(entity, XrmExtensions.GetAttributeLogicalName(loaderFunc));
return loaderFunc.Compile().Invoke(entity);
}

public IEnumerable<U> LoadEnumeration<T, U>(T entity, Expression<Func<T, IEnumerable<U>>> loaderFunc) where T : Entity
public IEnumerable<U> LoadEnumeration<T, U>(T entity, Expression<Func<T, IEnumerable<U>>> loaderFunc) where T : Microsoft.Xrm.Sdk.Entity
{
return Load(entity, loaderFunc) ?? new List<U>();
}
Expand All @@ -271,20 +270,20 @@ public IEnumerable<U> LoadEnumeration<T, U>(T entity, Expression<Func<T, IEnumer
public static class XrmExtensions
{

public static T Retrieve<T>(this IOrganizationService service, Guid id, params Expression<Func<T, object>>[] attributes) where T : Entity
public static T Retrieve<T>(this IOrganizationService service, Guid id, params Expression<Func<T, object>>[] attributes) where T : Microsoft.Xrm.Sdk.Entity
{
return service.Retrieve(Activator.CreateInstance<T>().LogicalName, id, GetColumnSet(attributes)).ToEntity<T>();
}

public static UpsertResponse Upsert(this IOrganizationService service, Entity entity)
public static UpsertResponse Upsert(this IOrganizationService service, Microsoft.Xrm.Sdk.Entity entity)
{
var req = new UpsertRequest() { Target = entity };
var resp = service.Execute(req) as UpsertResponse;
entity.Id = resp.Target?.Id ?? entity.Id;
return resp;
}


public static List<ExecuteMultipleResponseItem> PerformAsBulk<T>(this IOrganizationService service, IEnumerable<T> requests, bool continueOnError = true, int chunkSize = 1000) where T : OrganizationRequest
{
var arr = requests.ToArray();
Expand Down Expand Up @@ -332,34 +331,36 @@ public static string GetAttributeLogicalName<T, U>(Expression<Func<T, U>> lambda
return attributelogicalName.LogicalName;
}

public static bool ContainsAttributes<T>(this T entity, params Expression<Func<T, object>>[] attrGetters) where T : Entity
public static bool ContainsAttributes<T>(this T entity, params Expression<Func<T, object>>[] attrGetters) where T : Microsoft.Xrm.Sdk.Entity
{
if (attrGetters == null) return true;
return attrGetters.Select(a => GetAttributeLogicalName(a).ToLower()).All(a => entity.Contains(a));
}

public static bool RemoveAttributes<T>(this T entity, params Expression<Func<T, object>>[] attrGetters) where T : Entity
public static bool RemoveAttributes<T>(this T entity, params Expression<Func<T, object>>[] attrGetters) where T : Microsoft.Xrm.Sdk.Entity
{
if (attrGetters == null) return false;
return attrGetters.Select(a => GetAttributeLogicalName(a).ToLower()).Any(a => entity.Attributes.Remove(a));
}
}

[AttributeUsage(AttributeTargets.Field)]
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
public class OptionSetMetadataAttribute : Attribute
{
public string Name { get; private set; }
public int Index { get; set; }
public string Description { get; set; }
public string Color { get; set; }
public int Lcid { get; set; }

public OptionSetMetadataAttribute(string name, string description = null, string color = null) : this(name, int.MinValue, description, color) { }
public OptionSetMetadataAttribute(string name, int index, string description = null, string color = null)
public OptionSetMetadataAttribute(string name, int lcid = 1033, string description = null, string color = null) : this(name, int.MinValue, lcid, description, color) { }
public OptionSetMetadataAttribute(string name, int index, int lcid, string description = null, string color = null)
{
Name = name;
Index = index;
Description = description;
Color = color;
Lcid = lcid;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Microsoft.Xrm.Sdk.Metadata;
using Microsoft.Xrm.Sdk.Query;

using DG.XrmContext;
using DG.XrmFramework.BusinessDomain.ServiceContext;
using HU = DG.XrmFramework.BusinessLogic.Helpers.HelperUtils;

Expand Down
4 changes: 2 additions & 2 deletions XrmOrg/XrmOrg.XrmSolution/Tools/Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@
<Reference Include="XmlDiffPatch.View, Version=1.0.1493.40755, Culture=neutral">
<HintPath>..\packages\XMLDiffPatch.1.0.8.28\lib\net\XmlDiffPatch.View.dll</HintPath>
</Reference>
<Reference Include="XrmContext, Version=2.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Delegate.XrmContext.2.0.1\lib\net462\XrmContext.exe</HintPath>
<Reference Include="XrmContext, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Delegate.XrmContext.3.0.1\lib\net462\XrmContext.exe</HintPath>
</Reference>
<Reference Include="XrmDefinitelyTyped, Version=5.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Delegate.XrmDefinitelyTyped.5.5.0\lib\net462\XrmDefinitelyTyped.exe</HintPath>
Expand Down
Binary file not shown.
Binary file modified XrmOrg/XrmOrg.XrmSolution/Tools/XrmContext/XrmContext.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion XrmOrg/XrmOrg.XrmSolution/Tools/XrmContext/XrmContext.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion XrmOrg/XrmOrg.XrmSolution/Tools/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="Delegate.Daxif" version="5.1.1" targetFramework="net462" />
<package id="Delegate.Daxif.Scripts" version="1.0.0" targetFramework="net462" />
<package id="Delegate.XrmContext" version="2.0.1" targetFramework="net462" />
<package id="Delegate.XrmContext" version="3.0.1" targetFramework="net462" />
<package id="Delegate.XrmDefinitelyTyped" version="5.5.0" targetFramework="net462" />
<package id="FSharp.Core" version="4.7.2" targetFramework="net462" />
<package id="Microsoft.CrmSdk.CoreAssemblies" version="9.0.2.34" targetFramework="net462" />
Expand Down