Skip to content

Commit 73631b0

Browse files
authored
Merge pull request #124 from microsoft/release/update/210428091114
#20210428.1 Merged PR 584146: Fixes from GitHub
2 parents 035dd6d + 113cd5e commit 73631b0

File tree

7 files changed

+195
-107
lines changed

7 files changed

+195
-107
lines changed

src/Build.Shared.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<PackageVersion_AppInsights>2.9.1</PackageVersion_AppInsights>
66
<PackageVersion_Adal>3.19.8</PackageVersion_Adal>
77
<PackageVersion_MSAL>4.25.0</PackageVersion_MSAL>
8-
<PackageVersion_CdsSdk>4.6.3082-weekly-2103.4</PackageVersion_CdsSdk>
9-
<PackageVersion_CDSServerNuget>4.6.3082-weekly-2103.4</PackageVersion_CDSServerNuget>
8+
<PackageVersion_CdsSdk>4.6.3291-weekly-2104.2</PackageVersion_CdsSdk>
9+
<PackageVersion_CDSServerNuget>4.6.3291-weekly-2104.2</PackageVersion_CDSServerNuget>
1010
<PackageVersion_Newtonsoft>10.0.3</PackageVersion_Newtonsoft>
1111
<PackageVersion_RestClientRuntime>2.3.20</PackageVersion_RestClientRuntime>
1212
<PackageVersion_XrmSdk>9.0.2.25</PackageVersion_XrmSdk>

src/GeneralTools/DataverseClient/Client/ServiceClient.cs

Lines changed: 76 additions & 76 deletions
Large diffs are not rendered by default.

src/GeneralTools/DataverseClient/Client/Utils/Utils.cs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ internal static bool IsRequestValidForTranslationToWebAPI(OrganizationRequest re
319319
/// <param name="sourceEntity">Entity to process</param>
320320
/// <param name="mUtil"></param>
321321
/// <returns></returns>
322-
internal static ExpandoObject ToExpandoObject(Entity sourceEntity , MetadataUtility mUtil)
322+
internal static ExpandoObject ToExpandoObject(Entity sourceEntity, MetadataUtility mUtil)
323323
{
324324
dynamic expando = new ExpandoObject();
325325

@@ -328,7 +328,7 @@ internal static ExpandoObject ToExpandoObject(Entity sourceEntity , MetadataUtil
328328
sourceEntity = UpdateEntityAttributesForPrimaryId(sourceEntity, mUtil);
329329

330330
AttributeCollection entityAttributes = sourceEntity.Attributes;
331-
if (!(entityAttributes != null) && (entityAttributes.Count > 0 ))
331+
if (!(entityAttributes != null) && (entityAttributes.Count > 0))
332332
{
333333
return expando;
334334
}
@@ -346,8 +346,8 @@ internal static ExpandoObject ToExpandoObject(Entity sourceEntity , MetadataUtil
346346
var key = keyValuePair.Key;
347347
if (value is EntityReference entityReference)
348348
{
349-
// Get Lookup attribute meta data for the ER to check for polymorphic relationship.
350349
var attributeInfo = mUtil.GetAttributeMetadata(sourceEntity.LogicalName, key.ToLower());
350+
// Get Lookup attribute meta data for the ER to check for polymorphic relationship.
351351
if (attributeInfo is Xrm.Sdk.Metadata.LookupAttributeMetadata attribData)
352352
{
353353
// Now get relationship to make sure we use the correct name.
@@ -429,13 +429,23 @@ internal static ExpandoObject ToExpandoObject(Entity sourceEntity , MetadataUtil
429429
var attributeInfo = mUtil.GetAttributeMetadata(sourceEntity.LogicalName, key.ToLower());
430430
if (attributeInfo is Xrm.Sdk.Metadata.DateTimeAttributeMetadata attribDateTimeData)
431431
{
432-
if (attribDateTimeData.Format == Xrm.Sdk.Metadata.DateTimeFormat.DateOnly)
432+
if (attribDateTimeData.DateTimeBehavior == Xrm.Sdk.Metadata.DateTimeBehavior.DateOnly)
433433
{
434434
value = dateTimeValue.ToUniversalTime().ToString("yyyy-MM-dd");
435435
}
436436
else
437437
{
438-
value = dateTimeValue.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
438+
if (attribDateTimeData.DateTimeBehavior == Xrm.Sdk.Metadata.DateTimeBehavior.TimeZoneIndependent)
439+
{
440+
value = dateTimeValue.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fff");
441+
}
442+
else
443+
{
444+
if (attribDateTimeData.DateTimeBehavior == Xrm.Sdk.Metadata.DateTimeBehavior.UserLocal)
445+
{
446+
value = dateTimeValue.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
447+
}
448+
}
439449
}
440450
}
441451
}
@@ -453,6 +463,12 @@ internal static ExpandoObject ToExpandoObject(Entity sourceEntity , MetadataUtil
453463
}
454464
else if (value is null)
455465
{
466+
var attributeInfo = mUtil.GetAttributeMetadata(sourceEntity.LogicalName, key.ToLower());
467+
if (attributeInfo is Xrm.Sdk.Metadata.LookupAttributeMetadata attribData)
468+
{
469+
// Populate Key property
470+
key = $"{key}@odata.bind";
471+
}
456472
value = null;
457473
}
458474
}
@@ -479,7 +495,7 @@ internal static ExpandoObject ToExpandoObject(Entity sourceEntity , MetadataUtil
479495
/// <returns></returns>
480496
private static Entity UpdateEntityAttributesForPrimaryId(Entity sourceEntity, MetadataUtility mUtil)
481497
{
482-
if ( sourceEntity.Id != Guid.Empty )
498+
if (sourceEntity.Id != Guid.Empty)
483499
{
484500
var entMeta = mUtil.GetEntityMetadata(sourceEntity.LogicalName);
485501
sourceEntity.Attributes[entMeta.PrimaryIdAttribute] = sourceEntity.Id;
@@ -500,7 +516,7 @@ internal static ExpandoObject ReleatedEntitiesToExpandoObject(ExpandoObject root
500516
if (rootExpando == null)
501517
return rootExpando;
502518

503-
if ( entityCollection != null && entityCollection.Count == 0 )
519+
if (entityCollection != null && entityCollection.Count == 0)
504520
{
505521
// nothing to do, just return.
506522
return rootExpando;
@@ -547,7 +563,7 @@ internal static ExpandoObject ReleatedEntitiesToExpandoObject(ExpandoObject root
547563
key = ER12M.ReferencingAttribute;
548564
}
549565

550-
if ( string.IsNullOrEmpty(key) ) // Failed to find key
566+
if (string.IsNullOrEmpty(key)) // Failed to find key
551567
{
552568
throw new DataverseOperationException($"Relationship key {entItem.Key.SchemaName} cannot be found for related entities of {entityName}.");
553569
}
@@ -572,7 +588,7 @@ internal static ExpandoObject ReleatedEntitiesToExpandoObject(ExpandoObject root
572588
}
573589
childCollection?.Add((ExpandoObject)ent1);
574590
}
575-
if ( childCollection.Count == 1 && isArrayRequired == false)
591+
if (childCollection.Count == 1 && isArrayRequired == false)
576592
((IDictionary<string, object>)rootExpando).Add(key, childCollection[0]);
577593
else
578594
((IDictionary<string, object>)rootExpando).Add(key, childCollection);
@@ -735,7 +751,7 @@ internal static class FeatureVersionMinimums
735751
/// <param name="instanceVersion">Instance version of the Dataverse Instance</param>
736752
/// <param name="featureVersion">MinFeatureVersion</param>
737753
/// <returns></returns>
738-
internal static bool IsFeatureValidForEnviroment ( Version instanceVersion , Version featureVersion)
754+
internal static bool IsFeatureValidForEnviroment(Version instanceVersion, Version featureVersion)
739755
{
740756
if (instanceVersion != null && (instanceVersion >= featureVersion))
741757
return true;

0 commit comments

Comments
 (0)