BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtension.cs
/// <summary>
///     test if all entries in <see cref="BO4E.BO.Energiemenge.Energieverbrauch" /> do have same user properties.
///     Only tests for those user properties present. Missing user properties do not lead to false.
/// </summary>
/// <param name="em">Energiemenge</param>
/// <returns></returns>
test if all entries in  do have same user properties.
Only tests for those user properties present. Missing user properties do not lead to false.
test if all entries in do have same user properties . Only tests for those user properties present . Missing user properties do not lead to false .
public static bool IsPureUserProperties(this BO.Energiemenge em)
        {
            using (MiniProfiler.Current.Step(nameof(IsPureUserProperties)))
            {
                ISet<string> upKeys = new HashSet<string>(em.Energieverbrauch.Where(v => v.UserProperties != null)
                    .SelectMany(v => v.UserProperties.Keys));
                var values = new Dictionary<string, object>();
                foreach (var v in em.Energieverbrauch.Where(v => v.UserProperties != null))
                    foreach (var key in upKeys)
                        if (v.UserProperties.TryGetValue(key, out var rawValue))
                        {
                            if (values.TryGetValue(key, out var onlyValue))
                            {
                                if (rawValue == null && onlyValue != null)
                                    return false;
                                if (rawValue != null && !rawValue.Equals(onlyValue)) return false;
                            }
                            else
                            {
                                values.Add(key, rawValue);
                            }
                        }
                return true;
            }
        }
public static bool IsPureUserProperties ( this BO . Energiemenge em ) { using ( MiniProfiler . Current . Step ( nameof ( IsPureUserProperties ) ) ) { ISet < string > upKeys = new HashSet < string > ( em . Energieverbrauch . Where ( v => v . UserProperties != null ) . SelectMany ( v => v . UserProperties . Keys ) ) ; var values = new Dictionary < string , object > ( ) ; foreach ( var v in em . Energieverbrauch . Where ( v => v . UserProperties != null ) ) foreach ( var key in upKeys ) if ( v . UserProperties . TryGetValue ( key , out var rawValue ) ) { if ( values . TryGetValue ( key , out var onlyValue ) ) { if ( rawValue == null && onlyValue != null ) return false ; if ( rawValue != null && ! rawValue . Equals ( onlyValue ) ) return false ; } else { values . Add ( key , rawValue ) ; } } return true ; } }
test if all entries in  do have same user properties.
test if all entries in do have same user properties .
// ToDo: make it nice.
None
BO.Energiemenge
this
em
None