diff --git a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Client/PrimitiveKeys/PrimitiveKeysContainer.cs b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Client/PrimitiveKeys/PrimitiveKeysContainer.cs new file mode 100644 index 0000000000..21b1e6390b --- /dev/null +++ b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Client/PrimitiveKeys/PrimitiveKeysContainer.cs @@ -0,0 +1,2151 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// Generation date: 12/27/2024 12:58:35 PM +namespace Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys +{ + /// + /// There are no comments for Container in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("Container")] + public partial class Container : global::Microsoft.OData.Client.DataServiceContext + { + /// + /// Initialize a new Container object. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public Container(global::System.Uri serviceRoot) : + this(serviceRoot, global::Microsoft.OData.Client.ODataProtocolVersion.V4) + { + } + + /// + /// Initialize a new Container object. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public Container(global::System.Uri serviceRoot, global::Microsoft.OData.Client.ODataProtocolVersion protocolVersion) : + base(serviceRoot, protocolVersion) + { + this.ResolveName = new global::System.Func(this.ResolveNameFromType); + this.ResolveType = new global::System.Func(this.ResolveTypeFromName); + this.OnContextCreated(); + this.Format.LoadServiceModel = GeneratedEdmModel.GetInstance; + this.Format.UseJson(); + } + partial void OnContextCreated(); + /// + /// Since the namespace configured for this service reference + /// in Visual Studio is different from the one indicated in the + /// server schema, use type-mappers to map between the two. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected global::System.Type ResolveTypeFromName(string typeName) + { + global::System.Type resolvedType = this.DefaultResolveType(typeName, "Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys", "Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys"); + if ((resolvedType != null)) + { + return resolvedType; + } + return null; + } + /// + /// Since the namespace configured for this service reference + /// in Visual Studio is different from the one indicated in the + /// server schema, use type-mappers to map between the two. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected string ResolveNameFromType(global::System.Type clientType) + { + global::Microsoft.OData.Client.OriginalNameAttribute originalNameAttribute = (global::Microsoft.OData.Client.OriginalNameAttribute)global::System.Linq.Enumerable.SingleOrDefault(global::Microsoft.OData.Client.Utility.GetCustomAttributes(clientType, typeof(global::Microsoft.OData.Client.OriginalNameAttribute), true)); + if (clientType.Namespace.Equals("Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys", global::System.StringComparison.Ordinal)) + { + if (originalNameAttribute != null) + { + return string.Concat("Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.", originalNameAttribute.OriginalName); + } + return string.Concat("Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.", clientType.Name); + } + return null; + } + /// + /// There are no comments for EdmBinarySet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmBinarySet")] + public virtual global::Microsoft.OData.Client.DataServiceQuery EdmBinarySet + { + get + { + if ((this._EdmBinarySet == null)) + { + this._EdmBinarySet = base.CreateQuery("EdmBinarySet"); + } + return this._EdmBinarySet; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _EdmBinarySet; + /// + /// There are no comments for EdmBooleanSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmBooleanSet")] + public virtual global::Microsoft.OData.Client.DataServiceQuery EdmBooleanSet + { + get + { + if ((this._EdmBooleanSet == null)) + { + this._EdmBooleanSet = base.CreateQuery("EdmBooleanSet"); + } + return this._EdmBooleanSet; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _EdmBooleanSet; + /// + /// There are no comments for EdmByteSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmByteSet")] + public virtual global::Microsoft.OData.Client.DataServiceQuery EdmByteSet + { + get + { + if ((this._EdmByteSet == null)) + { + this._EdmByteSet = base.CreateQuery("EdmByteSet"); + } + return this._EdmByteSet; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _EdmByteSet; + /// + /// There are no comments for EdmDecimalSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmDecimalSet")] + public virtual global::Microsoft.OData.Client.DataServiceQuery EdmDecimalSet + { + get + { + if ((this._EdmDecimalSet == null)) + { + this._EdmDecimalSet = base.CreateQuery("EdmDecimalSet"); + } + return this._EdmDecimalSet; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _EdmDecimalSet; + /// + /// There are no comments for EdmDoubleSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmDoubleSet")] + public virtual global::Microsoft.OData.Client.DataServiceQuery EdmDoubleSet + { + get + { + if ((this._EdmDoubleSet == null)) + { + this._EdmDoubleSet = base.CreateQuery("EdmDoubleSet"); + } + return this._EdmDoubleSet; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _EdmDoubleSet; + /// + /// There are no comments for EdmSingleSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmSingleSet")] + public virtual global::Microsoft.OData.Client.DataServiceQuery EdmSingleSet + { + get + { + if ((this._EdmSingleSet == null)) + { + this._EdmSingleSet = base.CreateQuery("EdmSingleSet"); + } + return this._EdmSingleSet; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _EdmSingleSet; + /// + /// There are no comments for EdmGuidSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmGuidSet")] + public virtual global::Microsoft.OData.Client.DataServiceQuery EdmGuidSet + { + get + { + if ((this._EdmGuidSet == null)) + { + this._EdmGuidSet = base.CreateQuery("EdmGuidSet"); + } + return this._EdmGuidSet; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _EdmGuidSet; + /// + /// There are no comments for EdmInt16Set in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmInt16Set")] + public virtual global::Microsoft.OData.Client.DataServiceQuery EdmInt16Set + { + get + { + if ((this._EdmInt16Set == null)) + { + this._EdmInt16Set = base.CreateQuery("EdmInt16Set"); + } + return this._EdmInt16Set; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _EdmInt16Set; + /// + /// There are no comments for EdmInt32Set in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmInt32Set")] + public virtual global::Microsoft.OData.Client.DataServiceQuery EdmInt32Set + { + get + { + if ((this._EdmInt32Set == null)) + { + this._EdmInt32Set = base.CreateQuery("EdmInt32Set"); + } + return this._EdmInt32Set; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _EdmInt32Set; + /// + /// There are no comments for EdmInt64Set in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmInt64Set")] + public virtual global::Microsoft.OData.Client.DataServiceQuery EdmInt64Set + { + get + { + if ((this._EdmInt64Set == null)) + { + this._EdmInt64Set = base.CreateQuery("EdmInt64Set"); + } + return this._EdmInt64Set; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _EdmInt64Set; + /// + /// There are no comments for EdmStringSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmStringSet")] + public virtual global::Microsoft.OData.Client.DataServiceQuery EdmStringSet + { + get + { + if ((this._EdmStringSet == null)) + { + this._EdmStringSet = base.CreateQuery("EdmStringSet"); + } + return this._EdmStringSet; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _EdmStringSet; + /// + /// There are no comments for EdmTimeSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmTimeSet")] + public virtual global::Microsoft.OData.Client.DataServiceQuery EdmTimeSet + { + get + { + if ((this._EdmTimeSet == null)) + { + this._EdmTimeSet = base.CreateQuery("EdmTimeSet"); + } + return this._EdmTimeSet; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _EdmTimeSet; + /// + /// There are no comments for EdmDateTimeOffsetSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmDateTimeOffsetSet")] + public virtual global::Microsoft.OData.Client.DataServiceQuery EdmDateTimeOffsetSet + { + get + { + if ((this._EdmDateTimeOffsetSet == null)) + { + this._EdmDateTimeOffsetSet = base.CreateQuery("EdmDateTimeOffsetSet"); + } + return this._EdmDateTimeOffsetSet; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _EdmDateTimeOffsetSet; + /// + /// There are no comments for Folders in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Folders")] + public virtual global::Microsoft.OData.Client.DataServiceQuery Folders + { + get + { + if ((this._Folders == null)) + { + this._Folders = base.CreateQuery("Folders"); + } + return this._Folders; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _Folders; + /// + /// There are no comments for EdmBinarySet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToEdmBinarySet(EdmBinary edmBinary) + { + base.AddObject("EdmBinarySet", edmBinary); + } + /// + /// There are no comments for EdmBooleanSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToEdmBooleanSet(EdmBoolean edmBoolean) + { + base.AddObject("EdmBooleanSet", edmBoolean); + } + /// + /// There are no comments for EdmByteSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToEdmByteSet(EdmByte edmByte) + { + base.AddObject("EdmByteSet", edmByte); + } + /// + /// There are no comments for EdmDecimalSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToEdmDecimalSet(EdmDecimal edmDecimal) + { + base.AddObject("EdmDecimalSet", edmDecimal); + } + /// + /// There are no comments for EdmDoubleSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToEdmDoubleSet(EdmDouble edmDouble) + { + base.AddObject("EdmDoubleSet", edmDouble); + } + /// + /// There are no comments for EdmSingleSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToEdmSingleSet(EdmSingle edmSingle) + { + base.AddObject("EdmSingleSet", edmSingle); + } + /// + /// There are no comments for EdmGuidSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToEdmGuidSet(EdmGuid edmGuid) + { + base.AddObject("EdmGuidSet", edmGuid); + } + /// + /// There are no comments for EdmInt16Set in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToEdmInt16Set(EdmInt16 edmInt16) + { + base.AddObject("EdmInt16Set", edmInt16); + } + /// + /// There are no comments for EdmInt32Set in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToEdmInt32Set(EdmInt32 edmInt32) + { + base.AddObject("EdmInt32Set", edmInt32); + } + /// + /// There are no comments for EdmInt64Set in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToEdmInt64Set(EdmInt64 edmInt64) + { + base.AddObject("EdmInt64Set", edmInt64); + } + /// + /// There are no comments for EdmStringSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToEdmStringSet(EdmString edmString) + { + base.AddObject("EdmStringSet", edmString); + } + /// + /// There are no comments for EdmTimeSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToEdmTimeSet(EdmTime edmTime) + { + base.AddObject("EdmTimeSet", edmTime); + } + /// + /// There are no comments for EdmDateTimeOffsetSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToEdmDateTimeOffsetSet(EdmDateTimeOffset edmDateTimeOffset) + { + base.AddObject("EdmDateTimeOffsetSet", edmDateTimeOffset); + } + /// + /// There are no comments for Folders in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToFolders(Folder folder) + { + base.AddObject("Folders", folder); + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private abstract class GeneratedEdmModel + { + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::Microsoft.OData.Edm.IEdmModel ParsedModel = LoadModelFromString(); + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private const string filePath = @"PrimitiveKeysODataServiceCsdl.xml"; + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static global::Microsoft.OData.Edm.IEdmModel GetInstance() + { + return ParsedModel; + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::Microsoft.OData.Edm.IEdmModel LoadModelFromString() + { + global::System.Xml.XmlReader reader = CreateXmlReader(); + try + { + global::System.Collections.Generic.IEnumerable errors; + global::Microsoft.OData.Edm.IEdmModel edmModel; + + if (!global::Microsoft.OData.Edm.Csdl.CsdlReader.TryParse(reader, true, out edmModel, out errors)) + { + global::System.Text.StringBuilder errorMessages = new global::System.Text.StringBuilder(); + foreach (var error in errors) + { + errorMessages.Append(error.ErrorMessage); + errorMessages.Append("; "); + } + throw new global::System.InvalidOperationException(errorMessages.ToString()); + } + + return edmModel; + } + finally + { + ((global::System.IDisposable)(reader)).Dispose(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::System.Xml.XmlReader CreateXmlReader(string edmxToParse) + { + return global::System.Xml.XmlReader.Create(new global::System.IO.StringReader(edmxToParse)); + } + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::System.Xml.XmlReader CreateXmlReader() + { + try + { + var assembly = global::System.Reflection.Assembly.GetExecutingAssembly(); + // If multiple resource names end with the file name, select the shortest one. + var resourcePath = global::System.Linq.Enumerable.First( + global::System.Linq.Enumerable.OrderBy( + global::System.Linq.Enumerable.Where(assembly.GetManifestResourceNames(), name => name.EndsWith(filePath)), + filteredName => filteredName.Length)); + global::System.IO.Stream stream = assembly.GetManifestResourceStream(resourcePath); + return global::System.Xml.XmlReader.Create(new global::System.IO.StreamReader(stream)); + } + catch(global::System.Xml.XmlException e) + { + throw new global::System.Xml.XmlException("Failed to create an XmlReader from the stream. Check if the resource exists.", e); + } + } + } + } + /// + /// There are no comments for EdmBinarySingle in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmBinarySingle")] + public partial class EdmBinarySingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EdmBinarySingle object. + /// + public EdmBinarySingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new EdmBinarySingle object. + /// + public EdmBinarySingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new EdmBinarySingle object. + /// + public EdmBinarySingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + } + /// + /// There are no comments for EdmBinary in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("EdmBinarySet")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmBinary")] + public partial class EdmBinary : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new EdmBinary object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static EdmBinary CreateEdmBinary(byte[] ID) + { + EdmBinary edmBinary = new EdmBinary(); + edmBinary.Id = ID; + return edmBinary; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual byte[] Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private byte[] _Id; + partial void OnIdChanging(byte[] value); + partial void OnIdChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for EdmBooleanSingle in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmBooleanSingle")] + public partial class EdmBooleanSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EdmBooleanSingle object. + /// + public EdmBooleanSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new EdmBooleanSingle object. + /// + public EdmBooleanSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new EdmBooleanSingle object. + /// + public EdmBooleanSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + } + /// + /// There are no comments for EdmBoolean in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("EdmBooleanSet")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmBoolean")] + public partial class EdmBoolean : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new EdmBoolean object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static EdmBoolean CreateEdmBoolean(bool ID) + { + EdmBoolean edmBoolean = new EdmBoolean(); + edmBoolean.Id = ID; + return edmBoolean; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual bool Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private bool _Id; + partial void OnIdChanging(bool value); + partial void OnIdChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for EdmByteSingle in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmByteSingle")] + public partial class EdmByteSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EdmByteSingle object. + /// + public EdmByteSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new EdmByteSingle object. + /// + public EdmByteSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new EdmByteSingle object. + /// + public EdmByteSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + } + /// + /// There are no comments for EdmByte in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("EdmByteSet")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmByte")] + public partial class EdmByte : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new EdmByte object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static EdmByte CreateEdmByte(byte ID) + { + EdmByte edmByte = new EdmByte(); + edmByte.Id = ID; + return edmByte; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual byte Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private byte _Id; + partial void OnIdChanging(byte value); + partial void OnIdChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for EdmDecimalSingle in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmDecimalSingle")] + public partial class EdmDecimalSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EdmDecimalSingle object. + /// + public EdmDecimalSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new EdmDecimalSingle object. + /// + public EdmDecimalSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new EdmDecimalSingle object. + /// + public EdmDecimalSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + } + /// + /// There are no comments for EdmDecimal in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("EdmDecimalSet")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmDecimal")] + public partial class EdmDecimal : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new EdmDecimal object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static EdmDecimal CreateEdmDecimal(decimal ID) + { + EdmDecimal edmDecimal = new EdmDecimal(); + edmDecimal.Id = ID; + return edmDecimal; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual decimal Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private decimal _Id; + partial void OnIdChanging(decimal value); + partial void OnIdChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for EdmDoubleSingle in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmDoubleSingle")] + public partial class EdmDoubleSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EdmDoubleSingle object. + /// + public EdmDoubleSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new EdmDoubleSingle object. + /// + public EdmDoubleSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new EdmDoubleSingle object. + /// + public EdmDoubleSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + } + /// + /// There are no comments for EdmDouble in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("EdmDoubleSet")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmDouble")] + public partial class EdmDouble : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new EdmDouble object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static EdmDouble CreateEdmDouble(double ID) + { + EdmDouble edmDouble = new EdmDouble(); + edmDouble.Id = ID; + return edmDouble; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual double Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private double _Id; + partial void OnIdChanging(double value); + partial void OnIdChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for EdmSingleSingle in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmSingleSingle")] + public partial class EdmSingleSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EdmSingleSingle object. + /// + public EdmSingleSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new EdmSingleSingle object. + /// + public EdmSingleSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new EdmSingleSingle object. + /// + public EdmSingleSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + } + /// + /// There are no comments for EdmSingle in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("EdmSingleSet")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmSingle")] + public partial class EdmSingle : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new EdmSingle object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static EdmSingle CreateEdmSingle(float ID) + { + EdmSingle edmSingle = new EdmSingle(); + edmSingle.Id = ID; + return edmSingle; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual float Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private float _Id; + partial void OnIdChanging(float value); + partial void OnIdChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for EdmGuidSingle in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmGuidSingle")] + public partial class EdmGuidSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EdmGuidSingle object. + /// + public EdmGuidSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new EdmGuidSingle object. + /// + public EdmGuidSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new EdmGuidSingle object. + /// + public EdmGuidSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + } + /// + /// There are no comments for EdmGuid in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("EdmGuidSet")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmGuid")] + public partial class EdmGuid : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new EdmGuid object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static EdmGuid CreateEdmGuid(global::System.Guid ID) + { + EdmGuid edmGuid = new EdmGuid(); + edmGuid.Id = ID; + return edmGuid; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual global::System.Guid Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.Guid _Id; + partial void OnIdChanging(global::System.Guid value); + partial void OnIdChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for EdmInt16Single in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmInt16Single")] + public partial class EdmInt16Single : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EdmInt16Single object. + /// + public EdmInt16Single(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new EdmInt16Single object. + /// + public EdmInt16Single(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new EdmInt16Single object. + /// + public EdmInt16Single(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + } + /// + /// There are no comments for EdmInt16 in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("EdmInt16Set")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmInt16")] + public partial class EdmInt16 : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new EdmInt16 object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static EdmInt16 CreateEdmInt16(short ID) + { + EdmInt16 edmInt16 = new EdmInt16(); + edmInt16.Id = ID; + return edmInt16; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual short Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private short _Id; + partial void OnIdChanging(short value); + partial void OnIdChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for EdmInt32Single in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmInt32Single")] + public partial class EdmInt32Single : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EdmInt32Single object. + /// + public EdmInt32Single(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new EdmInt32Single object. + /// + public EdmInt32Single(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new EdmInt32Single object. + /// + public EdmInt32Single(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + } + /// + /// There are no comments for EdmInt32 in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("EdmInt32Set")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmInt32")] + public partial class EdmInt32 : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new EdmInt32 object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static EdmInt32 CreateEdmInt32(int ID) + { + EdmInt32 edmInt32 = new EdmInt32(); + edmInt32.Id = ID; + return edmInt32; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual int Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private int _Id; + partial void OnIdChanging(int value); + partial void OnIdChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for EdmInt64Single in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmInt64Single")] + public partial class EdmInt64Single : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EdmInt64Single object. + /// + public EdmInt64Single(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new EdmInt64Single object. + /// + public EdmInt64Single(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new EdmInt64Single object. + /// + public EdmInt64Single(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + } + /// + /// There are no comments for EdmInt64 in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("EdmInt64Set")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmInt64")] + public partial class EdmInt64 : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new EdmInt64 object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static EdmInt64 CreateEdmInt64(long ID) + { + EdmInt64 edmInt64 = new EdmInt64(); + edmInt64.Id = ID; + return edmInt64; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual long Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private long _Id; + partial void OnIdChanging(long value); + partial void OnIdChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for EdmStringSingle in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmStringSingle")] + public partial class EdmStringSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EdmStringSingle object. + /// + public EdmStringSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new EdmStringSingle object. + /// + public EdmStringSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new EdmStringSingle object. + /// + public EdmStringSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + } + /// + /// There are no comments for EdmString in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("EdmStringSet")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmString")] + public partial class EdmString : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new EdmString object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static EdmString CreateEdmString(string ID) + { + EdmString edmString = new EdmString(); + edmString.Id = ID; + return edmString; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual string Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private string _Id; + partial void OnIdChanging(string value); + partial void OnIdChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for EdmTimeSingle in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmTimeSingle")] + public partial class EdmTimeSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EdmTimeSingle object. + /// + public EdmTimeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new EdmTimeSingle object. + /// + public EdmTimeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new EdmTimeSingle object. + /// + public EdmTimeSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + } + /// + /// There are no comments for EdmTime in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("EdmTimeSet")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmTime")] + public partial class EdmTime : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new EdmTime object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static EdmTime CreateEdmTime(global::System.TimeSpan ID) + { + EdmTime edmTime = new EdmTime(); + edmTime.Id = ID; + return edmTime; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual global::System.TimeSpan Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.TimeSpan _Id; + partial void OnIdChanging(global::System.TimeSpan value); + partial void OnIdChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for EdmDateTimeOffsetSingle in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmDateTimeOffsetSingle")] + public partial class EdmDateTimeOffsetSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EdmDateTimeOffsetSingle object. + /// + public EdmDateTimeOffsetSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new EdmDateTimeOffsetSingle object. + /// + public EdmDateTimeOffsetSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new EdmDateTimeOffsetSingle object. + /// + public EdmDateTimeOffsetSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + } + /// + /// There are no comments for EdmDateTimeOffset in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("EdmDateTimeOffsetSet")] + [global::Microsoft.OData.Client.OriginalNameAttribute("EdmDateTimeOffset")] + public partial class EdmDateTimeOffset : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new EdmDateTimeOffset object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static EdmDateTimeOffset CreateEdmDateTimeOffset(global::System.DateTimeOffset ID) + { + EdmDateTimeOffset edmDateTimeOffset = new EdmDateTimeOffset(); + edmDateTimeOffset.Id = ID; + return edmDateTimeOffset; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual global::System.DateTimeOffset Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.DateTimeOffset _Id; + partial void OnIdChanging(global::System.DateTimeOffset value); + partial void OnIdChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for FolderSingle in the schema. + /// + [global::Microsoft.OData.Client.OriginalNameAttribute("FolderSingle")] + public partial class FolderSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new FolderSingle object. + /// + public FolderSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) {} + + /// + /// Initialize a new FolderSingle object. + /// + public FolderSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) {} + + /// + /// Initialize a new FolderSingle object. + /// + public FolderSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) {} + + /// + /// There are no comments for Parent in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Parent")] + public virtual global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.FolderSingle Parent + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Parent == null)) + { + this._Parent = new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.FolderSingle(this.Context, GetPath("Parent")); + } + return this._Parent; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.FolderSingle _Parent; + } + /// + /// There are no comments for Folder in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + [global::Microsoft.OData.Client.EntitySet("Folders")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Folder")] + public partial class Folder : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new Folder object. + /// + /// Initial value of Id. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static Folder CreateFolder(int ID) + { + Folder folder = new Folder(); + folder.Id = ID; + return folder; + } + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Id")] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(ErrorMessage = "Id is required.")] + public virtual int Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + this.OnPropertyChanged("Id"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private int _Id; + partial void OnIdChanging(int value); + partial void OnIdChanged(); + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Name")] + public virtual string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + this.OnPropertyChanged("Name"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + /// + /// There are no comments for Property Parent in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + [global::Microsoft.OData.Client.OriginalNameAttribute("Parent")] + public virtual global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.Folder Parent + { + get + { + return this._Parent; + } + set + { + this.OnParentChanging(value); + this._Parent = value; + this.OnParentChanged(); + this.OnPropertyChanged("Parent"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.Folder _Parent; + partial void OnParentChanging(global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.Folder value); + partial void OnParentChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// Class containing all extension methods + /// + public static class ExtensionMethods + { + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBinary as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBinarySingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBinarySingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBinarySingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBinary as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBinarySingle specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBinarySingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + byte[] id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBinarySingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBoolean as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBooleanSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBooleanSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBooleanSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBoolean as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBooleanSingle specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBooleanSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + bool id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBooleanSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmByte as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmByteSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmByteSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmByteSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmByte as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmByteSingle specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmByteSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + byte id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmByteSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDecimal as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDecimalSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDecimalSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDecimalSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDecimal as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDecimalSingle specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDecimalSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + decimal id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDecimalSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDouble as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDoubleSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDoubleSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDoubleSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDouble as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDoubleSingle specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDoubleSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + double id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDoubleSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmSingle as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmSingleSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmSingleSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmSingleSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmSingle as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmSingleSingle specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmSingleSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + float id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmSingleSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmGuid as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmGuidSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmGuidSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmGuidSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmGuid as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmGuidSingle specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmGuidSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + global::System.Guid id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmGuidSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt16 as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt16Single specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt16Single ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt16Single(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt16 as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt16Single specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt16Single ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + short id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt16Single(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt32 as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt32Single specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt32Single ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt32Single(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt32 as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt32Single specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt32Single ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + int id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt32Single(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt64 as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt64Single specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt64Single ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt64Single(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt64 as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt64Single specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt64Single ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + long id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt64Single(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmString as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmStringSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmStringSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmStringSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmString as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmStringSingle specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmStringSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + string id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmStringSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmTime as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmTimeSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmTimeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmTimeSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmTime as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmTimeSingle specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmTimeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + global::System.TimeSpan id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmTimeSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDateTimeOffset as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDateTimeOffsetSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDateTimeOffsetSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDateTimeOffsetSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDateTimeOffset as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDateTimeOffsetSingle specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDateTimeOffsetSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + global::System.DateTimeOffset id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDateTimeOffsetSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.Folder as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.FolderSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.FolderSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.FolderSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.Folder as global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.FolderSingle specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.FolderSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + int id) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.FolderSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + } +} diff --git a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Client/PrimitiveKeys/PrimitiveKeysODataServiceCsdl.xml b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Client/PrimitiveKeys/PrimitiveKeysODataServiceCsdl.xml new file mode 100644 index 0000000000..9314ed0b17 --- /dev/null +++ b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Client/PrimitiveKeys/PrimitiveKeysODataServiceCsdl.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Server/PrimitiveKeys/PrimitiveKeyValuesDataModel.cs b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Server/PrimitiveKeys/PrimitiveKeyValuesDataModel.cs new file mode 100644 index 0000000000..68ebb1d0d0 --- /dev/null +++ b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Server/PrimitiveKeys/PrimitiveKeyValuesDataModel.cs @@ -0,0 +1,89 @@ +//----------------------------------------------------------------------------- +// +// Copyright (c) .NET Foundation and Contributors. All rights reserved. +// See License.txt in the project root for license information. +// +//------------------------------------------------------------------------------ + +using EfKey = System.ComponentModel.DataAnnotations.KeyAttribute; + +namespace Microsoft.OData.Client.E2E.Tests.Common.Server.PrimitiveKeys +{ + [Key("Id")] + public class EdmBinary + { + public Byte[] Id { get; set; } + } + + [Key("Id")] + public class EdmBoolean + { + public Boolean Id { get; set; } + } + + [Key("Id")] + public class EdmByte + { + public Byte Id { get; set; } + } + + [Key("Id")] + public class EdmDecimal + { + public Decimal Id { get; set; } + } + + [Key("Id")] + public class EdmDouble + { + public Double Id { get; set; } + } + + [Key("Id")] + public class EdmSingle + { + public Single Id { get; set; } + } + + [Key("Id")] + public class EdmGuid + { + public Guid Id { get; set; } + } + + [Key("Id")] + public class EdmInt16 + { + public Int16 Id { get; set; } + } + + [Key("Id")] + public class EdmInt32 + { + public Int32 Id { get; set; } + } + + [Key("Id")] + public class EdmInt64 + { + public Int64 Id { get; set; } + } + + [Key("Id")] + public class EdmString + { + public String Id { get; set; } + } + + [Key("Id")] + public class EdmTime + { + public TimeSpan Id { get; set; } + } + + [Key("Id")] + public class EdmDateTimeOffset + { + public DateTimeOffset Id { get; set; } + } +} diff --git a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Server/PrimitiveKeys/PrimitiveKeyValuesDataSource.cs b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Server/PrimitiveKeys/PrimitiveKeyValuesDataSource.cs new file mode 100644 index 0000000000..e944403076 --- /dev/null +++ b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Server/PrimitiveKeys/PrimitiveKeyValuesDataSource.cs @@ -0,0 +1,277 @@ +//----------------------------------------------------------------------------- +// +// Copyright (c) .NET Foundation and Contributors. All rights reserved. +// See License.txt in the project root for license information. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.OData.Client.E2E.Tests.Common.Server.PrimitiveKeys +{ + public class PrimitiveKeyValuesDataSource + { + public static PrimitiveKeyValuesDataSource CreateInstance() + { + return new PrimitiveKeyValuesDataSource(); + } + + public PrimitiveKeyValuesDataSource() + { + ResetData(); + InitializeData(); + } + + private void InitializeData() + { + PopulateEdmBinaries(); + PopulateEdmBooleans(); + PopulateEdmBytes(); + PopulateEdmDecimals(); + PopulateEdmDoubles(); + PopulateEdmSingles(); + PopulateEdmGuids(); + PopulateEdmInt16s(); + PopulateEdmInt32s(); + PopulateEdmInt64s(); + PopulateEdmStrings(); + PopulateEdmTimes(); + PopulateEdmDateTimeOffsets(); + } + + private void ResetData() + { + this.EdmBinaries?.Clear(); + this.EdmBooleans?.Clear(); + this.EdmBytes?.Clear(); + this.EdmDecimals?.Clear(); + this.EdmDoubles?.Clear(); + this.EdmSingles?.Clear(); + this.EdmGuids?.Clear(); + this.EdmInt16s?.Clear(); + this.EdmInt32s?.Clear(); + this.EdmInt64s?.Clear(); + this.EdmStrings?.Clear(); + this.EdmTimes?.Clear(); + this.EdmDateTimeOffsets?.Clear(); + } + + public IList? EdmBinaries { get; set; } + public IList? EdmBooleans { get; set; } + public IList? EdmBytes { get; set; } + public IList? EdmDecimals { get; set; } + public IList? EdmDoubles { get; set; } + public IList? EdmSingles { get; set; } + public IList? EdmGuids { get; set; } + public IList? EdmInt16s { get; set; } + public IList? EdmInt32s { get; set; } + public IList? EdmInt64s { get; set; } + public IList? EdmStrings { get; set; } + public IList? EdmTimes { get; set; } + public IList? EdmDateTimeOffsets { get; set; } + + private void PopulateEdmBinaries() + { + this.EdmBinaries = + [ + new EdmBinary { Id = new Byte[] { } }, + new EdmBinary { Id = new Byte[] { 1 } }, + new EdmBinary { Id = new Byte[] { 2, 3, 4 } }, + ]; + } + + private void PopulateEdmBooleans() + { + this.EdmBooleans = + [ + new EdmBoolean { Id = true }, + new EdmBoolean { Id = false }, + ]; + } + + private void PopulateEdmBytes() + { + this.EdmBytes = + [ + new EdmByte { Id = Byte.MinValue }, + new EdmByte { Id = Byte.MaxValue }, + new EdmByte { Id = 0 }, + new EdmByte { Id = 1 }, + ]; + } + + private void PopulateEdmDecimals() + { + this.EdmDecimals = + [ + new EdmDecimal { Id = Decimal.MinValue }, + new EdmDecimal { Id = Decimal.MaxValue }, + new EdmDecimal { Id = Decimal.MinusOne }, + new EdmDecimal { Id = Decimal.One }, + new EdmDecimal { Id = Decimal.Zero }, + ]; + } + + private void PopulateEdmDoubles() + { + this.EdmDoubles = + [ + new EdmDouble { Id = Double.Epsilon }, + new EdmDouble { Id = Double.MaxValue }, + new EdmDouble { Id = Double.MinValue }, + new EdmDouble { Id = Double.NaN }, + new EdmDouble { Id = Double.NegativeInfinity }, + new EdmDouble { Id = Double.PositiveInfinity }, + new EdmDouble { Id = 0 }, + new EdmDouble { Id = -1 }, + new EdmDouble { Id = 1 }, + ]; + } + + private void PopulateEdmSingles() + { + this.EdmSingles = + [ + new EdmSingle { Id = Single.Epsilon }, + new EdmSingle { Id = Single.MaxValue }, + new EdmSingle { Id = Single.MinValue }, + new EdmSingle { Id = Single.NaN }, + new EdmSingle { Id = Single.NegativeInfinity }, + new EdmSingle { Id = Single.PositiveInfinity }, + new EdmSingle { Id = 0 }, + new EdmSingle { Id = -1 }, + new EdmSingle { Id = 1 }, + ]; + } + + private void PopulateEdmGuids() + { + this.EdmGuids = + [ + new EdmGuid { Id = Guid.NewGuid() }, + new EdmGuid { Id = Guid.Empty }, + ]; + } + + private void PopulateEdmInt16s() + { + this.EdmInt16s = + [ + new EdmInt16 { Id = Int16.MinValue }, + new EdmInt16 { Id = Int16.MaxValue }, + new EdmInt16 { Id = 0 }, + new EdmInt16 { Id = -1 }, + new EdmInt16 { Id = 1 }, + ]; + } + + private void PopulateEdmInt32s() + { + this.EdmInt32s = + [ + new EdmInt32 { Id = Int32.MinValue }, + new EdmInt32 { Id = Int32.MaxValue }, + new EdmInt32 { Id = 0 }, + new EdmInt32 { Id = -1 }, + new EdmInt32 { Id = 1 }, + ]; + } + + private void PopulateEdmInt64s() + { + this.EdmInt64s = + [ + new EdmInt64 { Id = Int64.MinValue }, + new EdmInt64 { Id = Int64.MaxValue }, + new EdmInt64 { Id = 0 }, + new EdmInt64 { Id = -1 }, + new EdmInt64 { Id = 1 }, + ]; + } + + private void PopulateEdmStrings() + { + this.EdmStrings = + [ + new EdmString { Id = "!" }, + new EdmString { Id = "!!" }, + new EdmString { Id = "!!!" }, + new EdmString { Id = "*" }, + new EdmString { Id = "**" }, + new EdmString { Id = "***" }, + new EdmString { Id = "(" }, + new EdmString { Id = "((" }, + new EdmString { Id = "(((" }, + new EdmString { Id = ")" }, + new EdmString { Id = "))" }, + new EdmString { Id = ")))" }, + new EdmString { Id = ";" }, + new EdmString { Id = ";;" }, + new EdmString { Id = ";;;" }, + new EdmString { Id = ":" }, + new EdmString { Id = "::" }, + new EdmString { Id = ":::" }, + new EdmString { Id = "@" }, + new EdmString { Id = "@@" }, + new EdmString { Id = "@@@" }, + new EdmString { Id = "&" }, + new EdmString { Id = "&&" }, + new EdmString { Id = "&&&" }, + new EdmString { Id = "=" }, + new EdmString { Id = "==" }, + new EdmString { Id = "===" }, + new EdmString { Id = "+" }, + new EdmString { Id = "++" }, + new EdmString { Id = "+++" }, + new EdmString { Id = "$" }, + new EdmString { Id = "$$" }, + new EdmString { Id = "$$$" }, + new EdmString { Id = "," }, + new EdmString { Id = ",," }, + new EdmString { Id = ",,," }, + new EdmString { Id = "[" }, + new EdmString { Id = "[[" }, + new EdmString { Id = "[[[" }, + new EdmString { Id = "]" }, + new EdmString { Id = "]]" }, + new EdmString { Id = "]]]" }, + new EdmString { Id = "{" }, + new EdmString { Id = "{{" }, + new EdmString { Id = "{{{" }, + new EdmString { Id = "}" }, + new EdmString { Id = "}}" }, + new EdmString { Id = "}}}" }, + new EdmString { Id = "?" }, + new EdmString { Id = "??" }, + new EdmString { Id = "???" }, + new EdmString { Id = "'" }, + new EdmString { Id = "''" }, + new EdmString { Id = "'''" }, + new EdmString { Id = "/" }, + new EdmString { Id = "//" }, + new EdmString { Id = "///" }, + new EdmString { Id = "\"" }, + new EdmString { Id = "\"\"" }, + new EdmString { Id = "\"\"\"" }, + new EdmString { Id = "SomeID" } + ]; + } + + private void PopulateEdmTimes() + { + this.EdmTimes = + [ + new EdmTime { Id = TimeSpan.MinValue }, + new EdmTime { Id = TimeSpan.MaxValue }, + new EdmTime { Id = TimeSpan.Zero }, + ]; + } + + private void PopulateEdmDateTimeOffsets() + { + this.EdmDateTimeOffsets = + [ + new EdmDateTimeOffset { Id = DateTimeOffset.MinValue }, + new EdmDateTimeOffset { Id = DateTimeOffset.MaxValue }, + ]; + } + } +} diff --git a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Server/PrimitiveKeys/PrimitiveKeyValuesEdmModel.cs b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Server/PrimitiveKeys/PrimitiveKeyValuesEdmModel.cs new file mode 100644 index 0000000000..19c56c8b12 --- /dev/null +++ b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Common/Server/PrimitiveKeys/PrimitiveKeyValuesEdmModel.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Copyright (c) .NET Foundation and Contributors. All rights reserved. +// See License.txt in the project root for license information. +// +//------------------------------------------------------------------------------ + +using Microsoft.OData.Edm; +using Microsoft.OData.ModelBuilder; + +namespace Microsoft.OData.Client.E2E.Tests.Common.Server.PrimitiveKeys +{ + public class PrimitiveKeyValuesEdmModel + { + public static IEdmModel GetEdmModel() + { + var builder = new ODataConventionModelBuilder(); + builder.EntitySet("EdmBinarySet"); + builder.EntitySet("EdmBooleanSet"); + builder.EntitySet("EdmByteSet"); + builder.EntitySet("EdmDecimalSet"); + builder.EntitySet("EdmDoubleSet"); + builder.EntitySet("EdmSingleSet"); + builder.EntitySet("EdmGuidSet"); + builder.EntitySet("EdmInt16Set"); + builder.EntitySet("EdmInt32Set"); + builder.EntitySet("EdmInt64Set"); + builder.EntitySet("EdmStringSet"); + builder.EntitySet("EdmTimeSet"); + builder.EntitySet("EdmDateTimeOffsetSet"); + + return builder.GetEdmModel(); + } + } +} diff --git a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Microsoft.OData.Client.E2E.Tests.csproj b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Microsoft.OData.Client.E2E.Tests.csproj index ab8a5503fe..b7b2a2dbb0 100644 --- a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Microsoft.OData.Client.E2E.Tests.csproj +++ b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/Microsoft.OData.Client.E2E.Tests.csproj @@ -14,6 +14,7 @@ + @@ -33,6 +34,9 @@ Always + + Always + diff --git a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Server/PrimitiveKeyValuesTestsController.cs b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Server/PrimitiveKeyValuesTestsController.cs new file mode 100644 index 0000000000..a0c9897bb9 --- /dev/null +++ b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Server/PrimitiveKeyValuesTestsController.cs @@ -0,0 +1,399 @@ +//--------------------------------------------------------------------- +// +// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. +// +//--------------------------------------------------------------------- + +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Formatter; +using Microsoft.AspNetCore.OData.Query; +using Microsoft.AspNetCore.OData.Routing.Controllers; +using Microsoft.OData.Client.E2E.Tests.Common.Server.PrimitiveKeys; + +namespace Microsoft.OData.Client.E2E.Tests.PrimitiveTypesTests.Server; + +public class PrimitiveKeyValuesTestsController : ODataController +{ + private static PrimitiveKeyValuesDataSource _dataSource; + + [EnableQuery] + [HttpGet("odata/EdmBinarySet")] + public IActionResult GetEdmBinaries() + { + var result = _dataSource.EdmBinaries; + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmBinarySet/{key}")] + public IActionResult GetEdmBinary([FromODataUri] byte[] key) + { + var result = _dataSource.EdmBinaries?.SingleOrDefault(a => a.Id.SequenceEqual(key)); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmBooleanSet")] + public IActionResult GetEdmBooleans() + { + var result = _dataSource.EdmBooleans; + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmBooleanSet/{key}")] + public IActionResult GetEdmBoolean([FromODataUri] bool key) + { + var result = _dataSource.EdmBooleans?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmBooleanSet({key})")] + public IActionResult GetEdmBooleanWithParentheses([FromODataUri] bool key) + { + var result = _dataSource.EdmBooleans?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmInt16Set")] + public IActionResult GetEdmInt16s() + { + var result = _dataSource.EdmInt16s; + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmInt16Set/{key}")] + public IActionResult GetEdmInt16([FromODataUri] short key) + { + var result = _dataSource.EdmInt16s?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmInt16Set({key})")] + public IActionResult GetEdmInt16WithParenthese([FromODataUri] short key) + { + var result = _dataSource.EdmInt16s?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmInt32Set")] + public IActionResult GetEdmInt32s() + { + var result = _dataSource.EdmInt32s; + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmInt32Set/{key}")] + public IActionResult GetEdmInt32([FromODataUri] int key) + { + var result = _dataSource.EdmInt32s?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmInt32Set({key})")] + public IActionResult GetEdmInt32WithParentheses([FromODataUri] int key) + { + var result = _dataSource.EdmInt32s?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + return Ok(result); + } + + [EnableQuery(PageSize = 2)] + [HttpGet("odata/EdmInt64Set")] + public IActionResult GetEdmInt64s() + { + var result = _dataSource.EdmInt64s; + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmInt64Set/$count")] + public IActionResult GetEdmInt64sCount() + { + var result = _dataSource.EdmInt64s; + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmInt64Set/{key}")] + public IActionResult GetEdmInt64([FromODataUri] long key) + { + var result = _dataSource.EdmInt64s?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmInt64Set({key})")] + public IActionResult GetEdmInt64WithParentheses([FromODataUri] long key) + { + var result = _dataSource.EdmInt64s?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery(PageSize = 2)] + [HttpGet("odata/EdmSingleSet")] + public IActionResult GetEdmSingles() + { + var result = _dataSource.EdmSingles; + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmSingleSet/$count")] + public IActionResult GetEdmSinglesCount() + { + var result = _dataSource.EdmSingles; + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmSingleSet/{key}")] + public IActionResult GetEdmSingle([FromODataUri] float key) + { + var result = _dataSource.EdmSingles?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmSingleSet({key})")] + public IActionResult GetEdmSingleWithParentheses([FromODataUri] float key) + { + var result = _dataSource.EdmSingles?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery(PageSize = 2)] + [HttpGet("odata/EdmDoubleSet")] + public IActionResult GetEdmDoubles() + { + var result = _dataSource.EdmDoubles; + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmDoubleSet/{key}")] + public IActionResult GetEdmDouble([FromODataUri] double key) + { + var result = _dataSource.EdmDoubles?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmDoubleSet({key})")] + public IActionResult GetEdmDoubleWithParentheses([FromODataUri] double key) + { + var result = _dataSource.EdmDoubles?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery(PageSize = 2)] + [HttpGet("odata/EdmDecimalSet")] + public IActionResult GetEdmDecimals() + { + var result = _dataSource.EdmDecimals; + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmDecimalSet/{key}")] + public IActionResult GetEdmDecimal([FromODataUri] decimal key) + { + var result = _dataSource.EdmDecimals?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + [EnableQuery] + [HttpGet("odata/EdmDecimalSet({key})")] + public IActionResult GetEdmDecimalWithParentheses([FromODataUri] decimal key) + { + var result = _dataSource.EdmDecimals?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmDateTimeOffsetSet")] + public IActionResult GetEdmDateTimeOffsets() + { + var result = _dataSource.EdmDateTimeOffsets; + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmDateTimeOffsetSet/{key}")] + public IActionResult GetEdmDateTimeOffset([FromODataUri] DateTimeOffset key) + { + var result = _dataSource.EdmDateTimeOffsets?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmDateTimeOffsetSet({key})")] + public IActionResult GetEdmDateTimeOffsetWithParentheses([FromODataUri] DateTimeOffset key) + { + var result = _dataSource.EdmDateTimeOffsets?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmTimeSet")] + public IActionResult GetEdmTimes() + { + var result = _dataSource.EdmTimes; + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmTimeSet/{key}")] + public IActionResult GetEdmTime([FromODataUri] TimeSpan key) + { + var result = _dataSource.EdmTimes?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmTimeSet({key})")] + public IActionResult GetEdmTimeWithParentheses([FromODataUri] TimeSpan key) + { + var result = _dataSource.EdmTimes?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + return Ok(result); + } + + [EnableQuery(PageSize = 2)] + [HttpGet("odata/EdmStringSet")] + public IActionResult GetEdmStrings() + { + var result = _dataSource.EdmStrings; + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmStringSet/{key}")] + public IActionResult GetEdmString([FromODataUri] string key) + { + var result = _dataSource.EdmStrings?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [EnableQuery] + [HttpGet("odata/EdmStringSet({key})")] + public IActionResult GetEdmStringWithParentheses([FromODataUri] string key) + { + var result = _dataSource.EdmStrings?.SingleOrDefault(a => a.Id == key); + if (result == null) + { + return NotFound(); + } + return Ok(result); + } + + [HttpPost("odata/primitivekeyvalues/Default.ResetDefaultDataSource")] + public IActionResult ResetDefaultDataSource() + { + _dataSource = PrimitiveKeyValuesDataSource.CreateInstance(); + + return Ok(); + } +} diff --git a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Server/PrimitiveTypesTestsController.cs b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Server/PrimitiveTypesTestsController.cs new file mode 100644 index 0000000000..0447c22f58 --- /dev/null +++ b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Server/PrimitiveTypesTestsController.cs @@ -0,0 +1,191 @@ +//--------------------------------------------------------------------- +// +// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. +// +//--------------------------------------------------------------------- + +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Deltas; +using Microsoft.AspNetCore.OData.Query; +using Microsoft.AspNetCore.OData.Routing.Controllers; +using Microsoft.OData.Client.E2E.Tests.Common.Server.Default; + +namespace Microsoft.OData.Client.E2E.Tests.PrimitiveTypesTests.Server; + +public class PrimitiveTypesTestsController : ODataController +{ + private static DefaultDataSource _dataSource; + + [EnableQuery] + [HttpGet("odata/Customers")] + public IActionResult GetCustomers() + { + var customers = _dataSource.Customers; + + return Ok(customers); + } + + [EnableQuery] + [HttpGet("odata/Customers({key})")] + public IActionResult GetCustomer([FromRoute] int key) + { + var customer = _dataSource.Customers?.SingleOrDefault(a => a.PersonID == key); + + if (customer == null) + { + return NotFound(); + } + + return Ok(customer); + } + + [EnableQuery] + [HttpGet("odata/Customers({key})/TimeBetweenLastTwoOrders")] + public IActionResult GetTimeBetweenLastTwoOrdersFromCustomer([FromRoute] int key) + { + var customer = _dataSource.Customers?.SingleOrDefault(a => a.PersonID == key); + + if (customer == null) + { + return NotFound(); + } + + return Ok(customer.TimeBetweenLastTwoOrders); + } + + [EnableQuery] + [HttpGet("odata/Customers({key})/TimeBetweenLastTwoOrders/$value")] + public IActionResult GetTimeBetweenLastTwoOrdersValueFromCustomer([FromRoute] int key) + { + var customer = _dataSource.Customers?.SingleOrDefault(a => a.PersonID == key); + + if (customer == null) + { + return NotFound(); + } + + return Ok(customer.TimeBetweenLastTwoOrders); + } + + [EnableQuery] + [HttpGet("odata/Orders")] + public IActionResult Orders() + { + var orders = _dataSource.Orders; + + return Ok(orders); + } + + [EnableQuery] + [HttpGet("odata/Orders()")] + public IActionResult GetOrders() + { + var orders = _dataSource.Orders; + + return Ok(orders); + } + + [EnableQuery] + [HttpGet("odata/Orders/$count")] + public IActionResult GetOrdersCount() + { + var count = _dataSource.Orders?.Count ?? 0; + return Ok(count); + } + + [EnableQuery] + [HttpGet("odata/Orders({key})")] + public IActionResult GetOrder([FromRoute] int key) + { + var order = _dataSource.Orders?.SingleOrDefault(o => o.OrderID == key); + + if(order == null) + { + return NotFound(); + } + + return Ok(order); + } + + [EnableQuery] + [HttpGet("odata/Orders({key})/CustomerForOrder")] + public IActionResult GetCustomerForOrderFromOrder([FromRoute] int key) + { + var order = _dataSource.Orders?.SingleOrDefault(o => o.OrderID == key); + + if (order == null) + { + return NotFound(); + } + + return Ok(order.CustomerForOrder); + } + + [HttpPost("odata/Orders")] + public IActionResult PostOrder([FromBody] Order order) + { + _dataSource.Orders.Add(order); + + return Created(order); + } + + [HttpPut("odata/Orders({key})")] + public IActionResult PutOrder([FromRoute] int key, [FromBody] Order order) + { + var existsOrder = _dataSource.Orders?.SingleOrDefault(o => o.OrderID == key); + + if (existsOrder == null) + { + return NotFound(); + } + + // Remove the current order from the data source + _dataSource.Orders.Remove(existsOrder); + + existsOrder.ShelfLife = order.ShelfLife; + existsOrder.OrderShelfLifes = order.OrderShelfLifes; + + // Add the updated order to the data source + _dataSource.Orders.Add(existsOrder); + + return Ok(existsOrder); + } + + [HttpPatch("odata/Orders({key})")] + public IActionResult PatchOrder([FromRoute] int key, [FromBody] Delta delta) + { + var order = _dataSource.Orders?.SingleOrDefault(o => o.OrderID == key); + + if (order == null) + { + return NotFound(); + } + + var updatedOrder = delta.Patch(order); + + return Ok(updatedOrder); + } + + [HttpDelete("odata/Orders({key})")] + public IActionResult PatchOrder([FromRoute] int key) + { + var order = _dataSource.Orders?.SingleOrDefault(o => o.OrderID == key); + + if (order == null) + { + return NotFound(); + } + + _dataSource.Orders.Remove(order); + + return NoContent(); + } + + [HttpPost("odata/primitivetypes/Default.ResetDefaultDataSource")] + public IActionResult ResetDefaultDataSource() + { + _dataSource = DefaultDataSource.CreateInstance(); + + return Ok(); + } +} diff --git a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/DurationTests.cs b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/DurationTests.cs new file mode 100644 index 0000000000..df7e987041 --- /dev/null +++ b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/DurationTests.cs @@ -0,0 +1,247 @@ +//--------------------------------------------------------------------- +// +// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. +// +//--------------------------------------------------------------------- + +using System.Collections.ObjectModel; +using System.Xml; +using Microsoft.AspNetCore.OData; +using Microsoft.AspNetCore.OData.Routing.Controllers; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OData.Client.E2E.TestCommon; +using Microsoft.OData.Client.E2E.TestCommon.Common; +using Microsoft.OData.Client.E2E.Tests.Common.Client.Default.Default; +using Microsoft.OData.Client.E2E.Tests.Common.Server.Default; +using Microsoft.OData.Client.E2E.Tests.PrimitiveTypesTests.Server; +using Microsoft.OData.Edm; +using Xunit; + +namespace Microsoft.OData.Client.E2E.Tests.PrimitiveTypesTests.Tests; + +public class DurationTests : EndToEndTestBase +{ + private readonly Uri _baseUri; + private readonly Container _context; + private readonly IEdmModel _model; + + public class TestsStartup : TestStartupBase + { + public override void ConfigureServices(IServiceCollection services) + { + services.ConfigureControllers(typeof(PrimitiveTypesTestsController), typeof(MetadataController)); + + services.AddControllers().AddOData(opt => + opt.EnableQueryFeatures().AddRouteComponents("odata", DefaultEdmModel.GetEdmModel())); + } + } + + public DurationTests(TestWebApplicationFactory fixture) + : base(fixture) + { + if(Client.BaseAddress == null) + { + throw new ArgumentNullException(nameof(Client.BaseAddress), "Base address cannot be null"); + } + + _baseUri = new Uri(Client.BaseAddress, "odata/"); + + _context = new Container(_baseUri) + { + HttpClientFactory = HttpClientFactory + }; + + _model = DefaultEdmModel.GetEdmModel(); + ResetDefaultDataSource(); + } + + // Constants + private const string MimeTypeODataParameterFullMetadata = MimeTypes.ApplicationJson + MimeTypes.ODataParameterFullMetadata; + private const string MimeTypeODataParameterMinimalMetadata = MimeTypes.ApplicationJson + MimeTypes.ODataParameterMinimalMetadata; + + #region Entity Set + + [Theory] + [InlineData(MimeTypeODataParameterFullMetadata)] + [InlineData(MimeTypeODataParameterMinimalMetadata)] + public async Task QueryEntitySetTest(string mimeType) + { + // Arrange & Act + var queryText = "Customers"; + var entries = await this.TestsHelper.QueryResourceSetsAsync(queryText, mimeType); + + entries = entries.Where(e => e.TypeName.EndsWith("Customer")).ToList(); + + // Assert + var timeBetweenLastTwoOrdersProperty = entries[0].Properties.Single(p => p.Name == "TimeBetweenLastTwoOrders") as ODataProperty; + Assert.NotNull(timeBetweenLastTwoOrdersProperty); + Assert.Equal(new TimeSpan(1), timeBetweenLastTwoOrdersProperty.Value); + + timeBetweenLastTwoOrdersProperty = entries[1].Properties.Single(p => p.Name == "TimeBetweenLastTwoOrders") as ODataProperty; + Assert.NotNull(timeBetweenLastTwoOrdersProperty); + Assert.Equal(new TimeSpan(2), timeBetweenLastTwoOrdersProperty.Value); + } + + #endregion + + #region Entity instance + + [Theory] + [InlineData(MimeTypeODataParameterFullMetadata)] + [InlineData(MimeTypeODataParameterMinimalMetadata)] + public async Task QueryEntityInstanceTest(string mimeType) + { + // Arrange & Act + var queryText = "Customers(1)"; + var entries = await this.TestsHelper.QueryResourceEntriesAsync(queryText, mimeType); + + var entry = entries.SingleOrDefault(e => e.TypeName.EndsWith("Customer")); + + // Assert + Assert.NotNull(entry); + + var timeBetweenLastTwoOrdersProperty = entry.Properties.Single(p => p.Name == "TimeBetweenLastTwoOrders") as ODataProperty; + Assert.NotNull(timeBetweenLastTwoOrdersProperty); + Assert.NotNull(timeBetweenLastTwoOrdersProperty.Value); + Assert.Equal(new TimeSpan(1), timeBetweenLastTwoOrdersProperty.Value); + } + + #endregion + + #region Entity property + + [Theory] + [InlineData(MimeTypeODataParameterFullMetadata)] + [InlineData(MimeTypeODataParameterMinimalMetadata)] + public async Task QueryEntityPropertyTest(string mimeType) + { + // Arrange & Act + var queryText = "Customers(1)/TimeBetweenLastTwoOrders"; + var property = await this.TestsHelper.QueryPropertyAsync(queryText, mimeType); + + // Assert + Assert.NotNull(property); + Assert.Equal(new TimeSpan(1), property.Value); + } + + #endregion + + #region Entity navigation + + [Theory] + [InlineData(MimeTypeODataParameterFullMetadata)] + [InlineData(MimeTypeODataParameterMinimalMetadata)] + public async Task QueryEntityNavigationTest(string mimeType) + { + // Arrange & Act + var queryText = "Orders(7)/CustomerForOrder"; + var entries = await this.TestsHelper.QueryResourceEntriesAsync(queryText, mimeType); + + var entry = entries.SingleOrDefault(e => e.TypeName.EndsWith("Customer")); + + // Assert + Assert.NotNull(entry); + + var timeBetweenLastTwoOrdersProperty = entry.Properties.Single(p => p.Name == "TimeBetweenLastTwoOrders") as ODataProperty; + Assert.NotNull(timeBetweenLastTwoOrdersProperty); + Assert.Equal(new TimeSpan(2), timeBetweenLastTwoOrdersProperty.Value); + } + + #endregion + + #region Entity property $value + + [Fact] + public async Task QueryEntityPropertyValueTest() + { + // Arrange & Act + var queryText = "Customers(1)/TimeBetweenLastTwoOrders/$value"; + var propertyValue = await this.TestsHelper.QueryPropertyValueInStringAsync(queryText); + + // Assert + Assert.Equal("PT0.0000001S", propertyValue); + } + + #endregion + + #region Insert and update property value + + [Fact] + public async Task InsertAndUpdatePropertyValueTest() + { + // Query with filter + var timespan = new TimeSpan((new Random()).Next()); + var orderQueryable = _context.Orders.Where(c => c.ShelfLife == timespan) as DataServiceQuery; + Assert.NotNull(orderQueryable); + Assert.EndsWith($"/Orders?$filter=ShelfLife eq duration'{XmlConvert.ToString(timespan)}'", orderQueryable.RequestUri.OriginalString, StringComparison.Ordinal); + Assert.Empty(orderQueryable.ToList()); + + int orderID = (new Random()).Next(); + + // Create an entity + var order = new Common.Client.Default.Order() + { + OrderID = orderID, + OrderDate = new DateTimeOffset(new DateTime(2011, 3, 4, 16, 3, 57)), + ShelfLife = timespan, + OrderShelfLifes = new ObservableCollection() { timespan } + }; + _context.AddToOrders(order); + await _context.SaveChangesAsync(); + + // Query and verify + var result = orderQueryable.ToList(); + Assert.Single(result); + Assert.Equal(orderID, result[0].OrderID); + + // Update the Duration properties + timespan = new TimeSpan((new Random()).Next()); + order.ShelfLife = timespan; + order.OrderShelfLifes = new ObservableCollection() { timespan }; + _context.UpdateObject(order); + await _context.SaveChangesAsync(SaveChangesOptions.ReplaceOnUpdate); + + // Query Duration property + var shelfLifeQueryable = _context.Orders.Where(c => c.OrderID == orderID).Select(c => new { c.ShelfLife }).FirstOrDefault(); + Assert.NotNull(shelfLifeQueryable); + Assert.NotNull(shelfLifeQueryable.ShelfLife); + Assert.Equal(timespan, shelfLifeQueryable.ShelfLife); + + // Query collection of Duration property + var orderShelfLifesQueryable = (from c in _context.Orders + where c.OrderID == orderID + select new { c.OrderShelfLifes }).FirstOrDefault(); + + Assert.NotNull(orderShelfLifesQueryable); + Assert.NotNull(orderShelfLifesQueryable.OrderShelfLifes); + Assert.Single(orderShelfLifesQueryable.OrderShelfLifes); + Assert.Equal(timespan, orderShelfLifesQueryable.OrderShelfLifes[0]); + + // Delete entity and validate + _context.DeleteObject(order); + await _context.SaveChangesAsync(SaveChangesOptions.ReplaceOnUpdate); + + var queryable = _context.Execute(new Uri($"Orders()?$filter=ShelfLife eq duration'{XmlConvert.ToString(timespan)}'", UriKind.Relative)); + Assert.Empty(queryable); + } + + #endregion + + #region Private methods + + private PrimitiveTypesTestsHelper TestsHelper + { + get + { + return new PrimitiveTypesTestsHelper(_baseUri, _model, Client); + } + } + + private void ResetDefaultDataSource() + { + var actionUri = new Uri(_baseUri + "primitivetypes/Default.ResetDefaultDataSource", UriKind.Absolute); + _context.Execute(actionUri, "POST"); + } + + #endregion +} diff --git a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/PrimitiveKeysValuesTests.cs b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/PrimitiveKeysValuesTests.cs new file mode 100644 index 0000000000..c339868b47 --- /dev/null +++ b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/PrimitiveKeysValuesTests.cs @@ -0,0 +1,455 @@ +//--------------------------------------------------------------------- +// +// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. +// +//--------------------------------------------------------------------- + +using Microsoft.AspNetCore.OData; +using Microsoft.AspNetCore.OData.Routing.Controllers; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OData.Client.E2E.TestCommon; +using Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys; +using Microsoft.OData.Client.E2E.Tests.Common.Server.PrimitiveKeys; +using Microsoft.OData.Client.E2E.Tests.PrimitiveTypesTests.Server; +using Microsoft.OData.Edm; +using Xunit; +using EdmBinary = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBinary; +using EdmBoolean = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmBoolean; +using EdmDateTimeOffset = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDateTimeOffset; +using EdmDecimal = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDecimal; +using EdmDouble = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDouble; +using EdmInt16 = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt16; +using EdmInt32 = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt32; +using EdmInt64 = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt64; +using EdmSingle = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmSingle; +using EdmString = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmString; +using EdmTime = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmTime; + +namespace Microsoft.OData.Client.E2E.Tests.PrimitiveTypesTests.Tests +{ + public class PrimitiveKeysValuesTests : EndToEndTestBase + { + private readonly Uri _baseUri; + private readonly Container _context; + private readonly IEdmModel _model; + + public class TestsStartup : TestStartupBase + { + public override void ConfigureServices(IServiceCollection services) + { + services.ConfigureControllers(typeof(PrimitiveKeyValuesTestsController), typeof(MetadataController)); + + services.AddControllers().AddOData(opt => + opt.EnableQueryFeatures().AddRouteComponents("odata", PrimitiveKeyValuesEdmModel.GetEdmModel())); + } + } + + public PrimitiveKeysValuesTests(TestWebApplicationFactory fixture) + : base(fixture) + { + if (Client.BaseAddress == null) + { + throw new ArgumentNullException(nameof(Client.BaseAddress), "Base address cannot be null"); + } + + _baseUri = new Uri(Client.BaseAddress, "odata/"); + + _context = new Container(_baseUri) + { + HttpClientFactory = HttpClientFactory + }; + + _model = PrimitiveKeyValuesEdmModel.GetEdmModel(); + ResetDefaultDataSource(); + } + + [Theory] + [InlineData(new Byte[] { }, "binary''")] + [InlineData(new Byte[] { 1 }, "binary'AQ%3D%3D'")] + [InlineData(new Byte[] { 2, 3, 4 }, "binary'AgME'")] + public void BinaryTest(byte[] entryId, string expectedIdInUrl) + { + // Arrange + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Slash; + + // Act + var query = _context.CreateQuery("EdmBinarySet").ByKey(entryId); + var queryResult = query.GetValue(); + + // Assert + Assert.EndsWith($"/odata/EdmBinarySet/{expectedIdInUrl}", query.RequestUri.AbsoluteUri); + Assert.NotNull(queryResult); + Assert.Equal(entryId, queryResult.Id); + + // DataServiceUrlKeyDelimiter.Parentheses + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Parentheses; + + var queryParentheses = _context.CreateQuery("EdmBinarySet").ByKey(entryId); + Assert.EndsWith($"/odata/EdmBinarySet({expectedIdInUrl})", queryParentheses.RequestUri.AbsoluteUri); + } + + [Theory] + [InlineData(true, "true")] + [InlineData(false, "false")] + public void BooleanTest(bool entryId, string expectedIdInUrl) + { + // Arrange + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Slash; + + // Act + var query = _context.CreateQuery("EdmBooleanSet").ByKey(entryId); + var queryResult = query.GetValue(); + + // Assert + Assert.EndsWith($"/odata/EdmBooleanSet/{expectedIdInUrl}", query.RequestUri.AbsoluteUri); + Assert.NotNull(queryResult); + Assert.Equal(entryId, queryResult.Id); + + // DataServiceUrlKeyDelimiter.Parentheses + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Parentheses; + + var queryParentheses = _context.CreateQuery("EdmBooleanSet").ByKey(entryId); + Assert.EndsWith($"/odata/EdmBooleanSet({expectedIdInUrl})", queryParentheses.RequestUri.AbsoluteUri); + } + + + public static TheoryData GetEdmDateTimeOffsetSet + { + get + { + return new TheoryData + { + { DateTimeOffset.MinValue, "0001-01-01T00:00:00Z" }, + { DateTimeOffset.MaxValue, "9999-12-31T23:59:59.9999999Z" } + }; + } + } + + [Theory] + [MemberData(nameof(GetEdmDateTimeOffsetSet))] + public void DateTimeOffsetTest(DateTimeOffset entryId, string expectedIdInUrl) + { + // Arrange + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Slash; + + // Act + var query = _context.CreateQuery("EdmDateTimeOffsetSet").ByKey(entryId); + var queryResult = query.GetValue(); + + // Assert + Assert.EndsWith($"/odata/EdmDateTimeOffsetSet/{expectedIdInUrl}", query.RequestUri.AbsoluteUri); + Assert.NotNull(queryResult); + Assert.Equal(entryId, queryResult.Id); + + // DataServiceUrlKeyDelimiter.Parentheses + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Parentheses; + + var queryParentheses = _context.CreateQuery("EdmDateTimeOffsetSet").ByKey(entryId); + Assert.EndsWith($"/odata/EdmDateTimeOffsetSet({expectedIdInUrl})", queryParentheses.RequestUri.AbsoluteUri); + } + + public static TheoryData GetEdmDecimalSet + { + get + { + return new TheoryData + { + { Decimal.Zero, "0" }, + { Decimal.MinusOne, "-1" }, + { Decimal.One, "1" } + }; + } + } + + [Theory] + [MemberData(nameof(GetEdmDecimalSet))] + public void DecimalTest(decimal entryId, string expectedIdInUrl) + { + // Arrange + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Slash; + + // Act + var query = _context.CreateQuery("EdmDecimalSet").ByKey(entryId); + var queryResult = query.GetValue(); + + // Assert + Assert.EndsWith($"/odata/EdmDecimalSet/{expectedIdInUrl}", query.RequestUri.AbsoluteUri); + Assert.NotNull(queryResult); + Assert.Equal(entryId, queryResult.Id); + + // DataServiceUrlKeyDelimiter.Parentheses + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Parentheses; + + var queryParentheses = _context.CreateQuery("EdmDecimalSet").ByKey(entryId); + Assert.EndsWith($"/odata/EdmDecimalSet({expectedIdInUrl})", queryParentheses.RequestUri.AbsoluteUri); + } + + [Theory] + [InlineData(0, "0.0")] + [InlineData(-1, "-1.0")] + [InlineData(1, "1.0")] + [InlineData(Double.MaxValue, "1.7976931348623157E%2B308")] + [InlineData(Double.MinValue, "-1.7976931348623157E%2B308")] + [InlineData(Double.Epsilon, "5E-324")] + [InlineData(Double.NegativeInfinity, "-INF")] + [InlineData(Double.PositiveInfinity, "INF")] + public void DoubleTest(double entryId, string expectedIdInUrl) + { + // Arrange + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Slash; + + // Act + var query = _context.CreateQuery("EdmDoubleSet").ByKey(entryId); + var queryResult = query.GetValue(); + + // Assert + Assert.EndsWith($"/odata/EdmDoubleSet/{expectedIdInUrl}", query.RequestUri.AbsoluteUri); + Assert.NotNull(queryResult); + Assert.Equal(entryId, queryResult.Id); + + // DataServiceUrlKeyDelimiter.Parentheses + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Parentheses; + + var queryParentheses = _context.CreateQuery("EdmDoubleSet").ByKey(entryId); + Assert.EndsWith($"/odata/EdmDoubleSet({expectedIdInUrl})", queryParentheses.RequestUri.AbsoluteUri); + } + + [Theory] + [InlineData(Int16.MinValue, "-32768")] + [InlineData(Int16.MaxValue, "32767")] + [InlineData(0, "0")] + [InlineData(-1, "-1")] + [InlineData(1, "1")] + public void Int16Test(short entryId, string expectedIdInUrl) + { + // Arrange + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Slash; + + // Act + var query = _context.CreateQuery("EdmInt16Set").ByKey(entryId); + var queryResult = query.GetValue(); + + // Assert + Assert.EndsWith($"/odata/EdmInt16Set/{expectedIdInUrl}", query.RequestUri.AbsoluteUri); + Assert.NotNull(queryResult); + Assert.Equal(entryId, queryResult.Id); + + // DataServiceUrlKeyDelimiter.Parentheses + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Parentheses; + + var queryParentheses = _context.CreateQuery("EdmInt16Set").ByKey(entryId); + Assert.EndsWith($"/odata/EdmInt16Set({expectedIdInUrl})", queryParentheses.RequestUri.AbsoluteUri); + } + + [Theory] + [InlineData(Int32.MinValue, "-2147483648")] + [InlineData(Int32.MaxValue, "2147483647")] + [InlineData(0, "0")] + [InlineData(-1, "-1")] + [InlineData(1, "1")] + public void Int32Test(int entryId, string expectedIdInUrl) + { + // Arrange + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Slash; + + // Act + var query = _context.CreateQuery("EdmInt32Set").ByKey(entryId); + var queryResult = query.GetValue(); + + // Assert + Assert.EndsWith($"/odata/EdmInt32Set/{expectedIdInUrl}", query.RequestUri.AbsoluteUri); + Assert.NotNull(queryResult); + Assert.Equal(entryId, queryResult.Id); + + // DataServiceUrlKeyDelimiter.Parentheses + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Parentheses; + + var queryParentheses = _context.CreateQuery("EdmInt32Set").ByKey(entryId); + Assert.EndsWith($"/odata/EdmInt32Set({expectedIdInUrl})", queryParentheses.RequestUri.AbsoluteUri); + } + + [Theory] + [InlineData(Int64.MinValue, "-9223372036854775808")] + [InlineData(Int64.MaxValue, "9223372036854775807")] + [InlineData(0, "0")] + [InlineData(-1, "-1")] + [InlineData(1, "1")] + public void Int64Test(long entryId, string expectedIdInUrl) + { + // Arrange + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Slash; + + // Act + var query = _context.CreateQuery("EdmInt64Set").ByKey(entryId); + var queryResult = query.GetValue(); + + // Assert + Assert.EndsWith($"/odata/EdmInt64Set/{expectedIdInUrl}", query.RequestUri.AbsoluteUri); + Assert.NotNull(queryResult); + Assert.Equal(entryId, queryResult.Id); + + // DataServiceUrlKeyDelimiter.Parentheses + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Parentheses; + + var queryParentheses = _context.CreateQuery("EdmInt64Set").ByKey(entryId); + Assert.EndsWith($"/odata/EdmInt64Set({expectedIdInUrl})", queryParentheses.RequestUri.AbsoluteUri); + } + + [Theory] + [InlineData(0, "0")] + [InlineData(-1, "-1")] + [InlineData(1, "1")] + [InlineData(float.MaxValue, "3.4028235E%2B38")] + [InlineData(float.MinValue, "-3.4028235E%2B38")] + [InlineData(float.Epsilon, "1E-45")] + public void SingleTest(float entryId, string expectedIdInUrl) + { + // Arrange + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Slash; + + // Act + var query = _context.CreateQuery("EdmSingleSet").ByKey(entryId); + var queryResult = query.GetValue(); + + // Assert + Assert.EndsWith($"/odata/EdmSingleSet/{expectedIdInUrl}", query.RequestUri.AbsoluteUri); + Assert.NotNull(queryResult); + Assert.Equal(entryId, queryResult.Id); + + // DataServiceUrlKeyDelimiter.Parentheses + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Parentheses; + + var queryParentheses = _context.CreateQuery("EdmSingleSet").ByKey(entryId); + Assert.EndsWith($"/odata/EdmSingleSet({expectedIdInUrl})", queryParentheses.RequestUri.AbsoluteUri); + } + + public static TheoryData GetEdmTimeSet + { + get + { + return new TheoryData + { + { TimeSpan.MinValue, "duration'-P10675199DT2H48M5.4775808S'" }, + { TimeSpan.MaxValue, "duration'P10675199DT2H48M5.4775807S'" }, + { TimeSpan.Zero, "duration'PT0S'" } + }; + } + } + + [Theory] + [MemberData(nameof(GetEdmTimeSet))] + public void TimeTest(TimeSpan entryId, string expectedIdInUrl) + { + // Arrange + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Slash; + + // Act + var query = _context.CreateQuery("EdmTimeSet").ByKey(entryId); + var queryResult = query.GetValue(); + + // Assert + Assert.EndsWith($"/odata/EdmTimeSet/{expectedIdInUrl}", query.RequestUri.AbsoluteUri); + Assert.NotNull(queryResult); + Assert.Equal(entryId, queryResult.Id); + + // DataServiceUrlKeyDelimiter.Parentheses + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Parentheses; + + var queryParentheses = _context.CreateQuery("EdmTimeSet").ByKey(entryId); + Assert.EndsWith($"/odata/EdmTimeSet({expectedIdInUrl})", queryParentheses.RequestUri.AbsoluteUri); + } + + [Theory] + [InlineData("!", "%21")] + [InlineData("!!", "%21%21")] + [InlineData("!!!", "%21%21%21")] + [InlineData("*", "%2A")] + [InlineData("**", "%2A%2A")] + [InlineData("***", "%2A%2A%2A")] + [InlineData("(", "%28")] + [InlineData("((", "%28%28")] + [InlineData("(((", "%28%28%28")] + [InlineData(")", "%29")] + [InlineData("))", "%29%29")] + [InlineData(")))", "%29%29%29")] + [InlineData(":", "%3A")] + [InlineData("::", "%3A%3A")] + [InlineData(":::", "%3A%3A%3A")] + [InlineData(";", "%3B")] + [InlineData(";;", "%3B%3B")] + [InlineData(";;;", "%3B%3B%3B")] + [InlineData("=", "%3D")] + [InlineData("==", "%3D%3D")] + [InlineData("===", "%3D%3D%3D")] + [InlineData("@", "%40")] + [InlineData("@@", "%40%40")] + [InlineData("@@@", "%40%40%40")] + [InlineData("[", "%5B")] + [InlineData("[[", "%5B%5B")] + [InlineData("[[[", "%5B%5B%5B")] + [InlineData("]", "%5D")] + [InlineData("]]", "%5D%5D")] + [InlineData("]]]", "%5D%5D%5D")] + [InlineData("}", "%7D")] + [InlineData("}}", "%7D%7D")] + [InlineData("}}}", "%7D%7D%7D")] + [InlineData("{", "%7B")] + [InlineData("{{", "%7B%7B")] + [InlineData("{{{", "%7B%7B%7B")] + [InlineData("?", "%3F")] + [InlineData("??", "%3F%3F")] + [InlineData("???", "%3F%3F%3F")] + [InlineData("&", "%26")] + [InlineData("&&", "%26%26")] + [InlineData("&&&", "%26%26%26")] + [InlineData("$", "%24")] + [InlineData("$$", "%24%24")] + [InlineData("$$$", "%24%24%24")] + [InlineData(",", "%2C")] + [InlineData(",,", "%2C%2C")] + [InlineData(",,,", "%2C%2C%2C")] + [InlineData("+", "%2B")] + [InlineData("++", "%2B%2B")] + [InlineData("+++", "%2B%2B%2B")] + [InlineData("'", "''")] + [InlineData("''", "''''")] + [InlineData("'''", "''''''")] + [InlineData("/", "%2F")] + [InlineData("//", "%2F%2F")] + [InlineData("///", "%2F%2F%2F")] + [InlineData("\"", "%22")] + [InlineData("\"\"", "%22%22")] + [InlineData("\"\"\"", "%22%22%22")] + [InlineData("SomeID", "SomeID")] + public void StringTest(string entryId, string expectedIdInUrl) + { + // Arrange + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Slash; + + // Act + var query = _context.CreateQuery("EdmStringSet").ByKey(entryId); + var queryResult = query.GetValue(); + + // Assert + Assert.EndsWith($"/odata/EdmStringSet/'{expectedIdInUrl}'", query.RequestUri.AbsoluteUri); + Assert.NotNull(queryResult); + Assert.Equal(entryId, queryResult.Id); + + // DataServiceUrlKeyDelimiter.Parentheses + _context.UrlKeyDelimiter = DataServiceUrlKeyDelimiter.Parentheses; + + var queryParentheses = _context.CreateQuery("EdmStringSet").ByKey(entryId); + Assert.EndsWith($"/odata/EdmStringSet('{expectedIdInUrl}')", queryParentheses.RequestUri.AbsoluteUri); + } + + #region Private + + private void ResetDefaultDataSource() + { + var actionUri = new Uri(_baseUri + "primitivekeyvalues/Default.ResetDefaultDataSource", UriKind.Absolute); + _context.Execute(actionUri, "POST"); + } + + #endregion + } +} diff --git a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/PrimitiveTypesTestsHelper.cs b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/PrimitiveTypesTestsHelper.cs new file mode 100644 index 0000000000..214e0247e4 --- /dev/null +++ b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/PrimitiveTypesTestsHelper.cs @@ -0,0 +1,244 @@ +//--------------------------------------------------------------------- +// +// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. +// +//--------------------------------------------------------------------- + +using Microsoft.OData.Client.E2E.TestCommon.Common; +using Microsoft.OData.Edm; +using Xunit; + +namespace Microsoft.OData.Client.E2E.Tests.PrimitiveTypesTests.Tests; + +public class PrimitiveTypesTestsHelper +{ + private readonly Uri BaseUri; + private readonly IEdmModel Model; + private readonly HttpClient Client; + private const string IncludeAnnotation = "odata.include-annotations"; + + public PrimitiveTypesTestsHelper(Uri baseUri, IEdmModel model, HttpClient client) + { + this.BaseUri = baseUri; + this.Model = model; + this.Client = client; + } + + /// + /// Queries resource entries asynchronously based on the provided query text and MIME type. + /// + /// The query text to append to the base URI. + /// The MIME type to set in the request header. + /// A task that represents the asynchronous operation. The task result contains a list of . + public async Task> QueryResourceEntriesAsync(string queryText, string mimeType) + + { + ODataMessageReaderSettings readerSettings = new() { BaseUri = BaseUri }; + var requestUrl = new Uri(BaseUri.AbsoluteUri + queryText, UriKind.Absolute); + + var requestMessage = new TestHttpClientRequestMessage(requestUrl, Client); + requestMessage.SetHeader("Accept", mimeType); + requestMessage.SetHeader("Prefer", string.Format("{0}={1}", IncludeAnnotation, "*")); + + var responseMessage = await requestMessage.GetResponseAsync(); + + Assert.Equal(200, responseMessage.StatusCode); + + var entries = new List(); + if (!mimeType.Contains(MimeTypes.ODataParameterNoMetadata)) + { + using (var messageReader = new ODataMessageReader(responseMessage, readerSettings, Model)) + { + var reader = await messageReader.CreateODataResourceReaderAsync(); + while (await reader.ReadAsync()) + { + if (reader.State == ODataReaderState.ResourceEnd && reader.Item is ODataResource odataResource) + { + entries.Add(odataResource); + } + } + Assert.Equal(ODataReaderState.Completed, reader.State); + } + } + + return entries; + } + + /// + /// Queries resource sets asynchronously based on the provided query text and MIME type. + /// + /// The query text to append to the base URI. + /// The MIME type to set in the request header. + /// A task that represents the asynchronous operation. The task result contains a list of . + public async Task> QueryResourceSetsAsync(string queryText, string mimeType) + + { + ODataMessageReaderSettings readerSettings = new() { BaseUri = BaseUri }; + var requestUrl = new Uri(BaseUri.AbsoluteUri + queryText, UriKind.Absolute); + + var requestMessage = new TestHttpClientRequestMessage(requestUrl, Client); + requestMessage.SetHeader("Accept", mimeType); + + var responseMessage = await requestMessage.GetResponseAsync(); + + Assert.Equal(200, responseMessage.StatusCode); + + var entries = new List(); + if (!mimeType.Contains(MimeTypes.ODataParameterNoMetadata)) + { + using (var messageReader = new ODataMessageReader(responseMessage, readerSettings, Model)) + { + var reader = await messageReader.CreateODataResourceSetReaderAsync(); + while (await reader.ReadAsync()) + { + if (reader.State == ODataReaderState.ResourceEnd) + { + if (reader.Item is ODataResource odataResource) + { + entries.Add(odataResource); + } + } + } + Assert.Equal(ODataReaderState.Completed, reader.State); + } + } + + return entries; + } + + /// + /// Queries an OData resource and OData resource set asynchronously based on the provided query text and MIME type. + /// + /// The query text to append to the base URI. + /// The MIME type to set in the request header. + /// A task that represents the asynchronous operation. The task result contains a tuple of list of and list of . + public async Task<(List, List)> QueryResourceAndResourceSetsAsync(string queryText, string mimeType) + { + ODataMessageReaderSettings readerSettings = new() { BaseUri = BaseUri }; + var requestUrl = new Uri(BaseUri.AbsoluteUri + queryText, UriKind.Absolute); + + var requestMessage = new TestHttpClientRequestMessage(requestUrl, Client); + requestMessage.SetHeader("Accept", mimeType); + + var responseMessage = await requestMessage.GetResponseAsync(); + + Assert.Equal(200, responseMessage.StatusCode); + + var resourceEntries = new List(); + var resourceSetEntries = new List(); + if (!mimeType.Contains(MimeTypes.ODataParameterNoMetadata)) + { + using (var messageReader = new ODataMessageReader(responseMessage, readerSettings, Model)) + { + var reader = await messageReader.CreateODataResourceSetReaderAsync(); + while (await reader.ReadAsync()) + { + if (reader.State == ODataReaderState.ResourceEnd && reader.Item is ODataResource odataResource) + { + resourceEntries.Add(odataResource); + } + else if(reader.State == ODataReaderState.ResourceSetEnd && reader.Item is ODataResourceSet odataResourceSet) + { + resourceSetEntries.Add(odataResourceSet); + } + } + Assert.Equal(ODataReaderState.Completed, reader.State); + } + + } + + return (resourceEntries, resourceSetEntries); + } + + /// + /// Queries an OData resource set asynchronously based on the provided query text and MIME type. + /// + /// The query text to append to the base URI. + /// The MIME type to set in the request header. + /// A task that represents the asynchronous operation. The task result contains an if found; otherwise, null. + public async Task QueryODataResourceSetAsync(string queryText, string mimeType) + { + ODataMessageReaderSettings readerSettings = new() { BaseUri = BaseUri }; + var requestUrl = new Uri(BaseUri.AbsoluteUri + queryText, UriKind.Absolute); + + var requestMessage = new TestHttpClientRequestMessage(requestUrl, Client); + requestMessage.SetHeader("Accept", mimeType); + + var responseMessage = await requestMessage.GetResponseAsync(); + + Assert.Equal(200, responseMessage.StatusCode); + + if (!mimeType.Contains(MimeTypes.ODataParameterNoMetadata)) + { + using (var messageReader = new ODataMessageReader(responseMessage, readerSettings, Model)) + { + var reader = await messageReader.CreateODataResourceReaderAsync(); + while (await reader.ReadAsync()) + { + if (reader.State == ODataReaderState.ResourceSetEnd && reader.Item is ODataResourceSet oDataResourceSet) + { + return oDataResourceSet; + } + } + } + } + + return null; + } + + /// + /// Queries a property asynchronously based on the provided request URI and MIME type. + /// + /// The request URI to append to the base URI. + /// The MIME type to set in the request header. + /// A task that represents the asynchronous operation. The task result contains an if found; otherwise, null. + public async Task QueryPropertyAsync(string requestUri, string mimeType) + { + var readerSettings = new ODataMessageReaderSettings() { BaseUri = BaseUri }; + + var uri = new Uri(BaseUri.AbsoluteUri + requestUri, UriKind.Absolute); + var requestMessage = new TestHttpClientRequestMessage(uri, Client); + + requestMessage.SetHeader("Accept", mimeType); + + var responseMessage = await requestMessage.GetResponseAsync(); + + Assert.Equal(200, responseMessage.StatusCode); + + ODataProperty? property = null; + + if (!mimeType.Contains(MimeTypes.ODataParameterNoMetadata)) + { + using (var messageReader = new ODataMessageReader(responseMessage, readerSettings, Model)) + { + property = messageReader.ReadProperty(); + } + } + + return property; + } + + /// + /// Queries a property value in string asynchronously based on the provided request URI. + /// + /// The query text to append to the base URI. + /// A task that represents the asynchronous operation. The task result contains an if found; otherwise, null. + public async Task QueryPropertyValueInStringAsync(string requestUri) + { + var readerSettings = new ODataMessageReaderSettings() { BaseUri = BaseUri }; + + var uri = new Uri(BaseUri.AbsoluteUri + requestUri, UriKind.Absolute); + var requestMessage = new TestHttpClientRequestMessage(uri, Client); + + requestMessage.SetHeader("Accept", "*/*"); + + var responseMessage = await requestMessage.GetResponseAsync(); + + Assert.Equal(200, responseMessage.StatusCode); + + using (var messageReader = new ODataMessageReader(responseMessage, readerSettings, Model)) + { + return messageReader.ReadValue(EdmCoreModel.Instance.GetString(false)); + } + } +} diff --git a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/PrimitiveValueFormatTest.cs b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/PrimitiveValueFormatTest.cs new file mode 100644 index 0000000000..46c1dbbf52 --- /dev/null +++ b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/PrimitiveValueFormatTest.cs @@ -0,0 +1,516 @@ +//--------------------------------------------------------------------- +// +// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. +// +//--------------------------------------------------------------------- + +using Microsoft.AspNetCore.OData; +using Microsoft.AspNetCore.OData.Routing.Controllers; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OData.Client.E2E.TestCommon; +using Microsoft.OData.Client.E2E.TestCommon.Common; +using Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys; +using Microsoft.OData.Client.E2E.Tests.Common.Server.PrimitiveKeys; +using Microsoft.OData.Client.E2E.Tests.PrimitiveTypesTests.Server; +using Microsoft.OData.Edm; +using Xunit; +using EdmDecimal = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDecimal; +using EdmDouble = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmDouble; +using EdmInt64 = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmInt64; +using EdmSingle = Microsoft.OData.Client.E2E.Tests.Common.Client.PrimitiveKeys.EdmSingle; + +namespace Microsoft.OData.Client.E2E.Tests.PrimitiveTypesTests.Tests; + +public class PrimitiveValueFormatTest : EndToEndTestBase +{ + private readonly Uri _baseUri; + private readonly Container _context; + private readonly IEdmModel _model; + + public class TestsStartup : TestStartupBase + { + public override void ConfigureServices(IServiceCollection services) + { + services.ConfigureControllers(typeof(PrimitiveKeyValuesTestsController), typeof(MetadataController)); + + services.AddControllers().AddOData(opt => + opt.EnableQueryFeatures().AddRouteComponents("odata", PrimitiveKeyValuesEdmModel.GetEdmModel())); + } + } + + public PrimitiveValueFormatTest(TestWebApplicationFactory fixture) + : base(fixture) + { + if (Client.BaseAddress == null) + { + throw new ArgumentNullException(nameof(Client.BaseAddress), "Base address cannot be null"); + } + + _baseUri = new Uri(Client.BaseAddress, "odata/"); + + _context = new Container(_baseUri) + { + HttpClientFactory = HttpClientFactory + }; + + _model = PrimitiveKeyValuesEdmModel.GetEdmModel(); + ResetDefaultDataSource(); + } + + public string DataPattern = "(" + @"[\+-]?\d\.?\d*E?[\+-]?\d*" + "|" + @"INF|-INF|NaN" + ")"; + private const string MimeTypeODataParameterFullMetadata = MimeTypes.ApplicationJson + MimeTypes.ODataParameterFullMetadata; + private const string MimeTypeODataParameterFullMetadataAndIEEE754Compatible = MimeTypes.ApplicationJson + MimeTypes.ODataParameterFullMetadata + MimeTypes.ODataParameterIEEE754Compatible; + + [Theory] + [InlineData("EdmInt64Set(1)")] + [InlineData("EdmInt64Set(1L)")] + [InlineData("EdmInt64Set(1l)")] + public async Task LongWithOrWithoutSuffixAsKeyInURLTest(string keySegment) + { + // Arrange + var mimeType = MimeTypes.ApplicationJson + MimeTypes.ODataParameterFullMetadata; + var expectedKeySegment = "EdmInt64Set(1)"; + + // Act + var entries = await TestsHelper.QueryResourceEntriesAsync(keySegment, mimeType); + var entry = entries.SingleOrDefault(); + + // Assert + Assert.Single(entries); + Assert.NotNull(entry); + Assert.Contains(expectedKeySegment, entry.Id.ToString()); + Assert.Contains(expectedKeySegment, entry.EditLink.ToString()); + Assert.Contains(expectedKeySegment, entry.ReadLink.ToString()); + } + + [Theory] + [InlineData("EdmSingleSet(1.0)")] + [InlineData("EdmSingleSet(1.0F)")] + [InlineData("EdmSingleSet(1.0f)")] + public async Task FloatWithOrWithoutSuffixAsKeyInURLTest(string keySegment) + { + // Arrange + var mimeType = MimeTypes.ApplicationJson + MimeTypes.ODataParameterFullMetadata; + var expectedKeySegment = "EdmSingleSet(1)"; + + // Act + var entries = await TestsHelper.QueryResourceEntriesAsync(keySegment, mimeType); + var entry = entries.SingleOrDefault(); + + // Assert + Assert.Single(entries); + Assert.NotNull(entry); + Assert.Contains(expectedKeySegment, entry.Id.ToString()); + Assert.Contains(expectedKeySegment, entry.EditLink.ToString()); + Assert.Contains(expectedKeySegment, entry.ReadLink.ToString()); + } + + [Theory] + [InlineData("EdmDoubleSet(1.0)")] + [InlineData("EdmDoubleSet(1.0D)")] + [InlineData("EdmDoubleSet(1.0d)")] + public async Task DoubleWithOrWithoutSuffixAsKeyInURLTest(string keySegment) + { + // Arrange + var mimeType = MimeTypes.ApplicationJson + MimeTypes.ODataParameterFullMetadata; + var expectedKeySegment = "EdmDoubleSet(1.0)"; + + // Act + var entries = await TestsHelper.QueryResourceEntriesAsync(keySegment, mimeType); + var entry = entries.SingleOrDefault(); + + // Assert + Assert.Single(entries); + Assert.NotNull(entry); + Assert.Contains(expectedKeySegment, entry.Id.ToString()); + Assert.Contains(expectedKeySegment, entry.EditLink.ToString()); + Assert.Contains(expectedKeySegment, entry.ReadLink.ToString()); + } + + [Theory] + [InlineData("EdmDecimalSet(1.0)")] + [InlineData("EdmDecimalSet(1.0M)")] + [InlineData("EdmDecimalSet(1.0m)")] + public async Task DecimalWithOrWithoutSuffixAsKeyInURLTest(string keySegment) + { + // Arrange + var mimeType = MimeTypes.ApplicationJson + MimeTypes.ODataParameterFullMetadata; + var expectedKeySegment = "EdmDecimalSet(1)"; + + // Act + var entries = await TestsHelper.QueryResourceEntriesAsync(keySegment, mimeType); + var entry = entries.SingleOrDefault(); + + // Assert + Assert.Single(entries); + Assert.NotNull(entry); + Assert.Contains(expectedKeySegment, entry.Id.ToString()); + Assert.Contains(expectedKeySegment, entry.EditLink.ToString()); + Assert.Contains(expectedKeySegment, entry.ReadLink.ToString()); + } + + [Theory] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmInt64Set?$filter=Id ge -1")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmInt64Set?$filter=Id ge -1L")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmInt64Set?$filter=Id ge -1l")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmInt64Set?$filter=Id ge -1")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmInt64Set?$filter=Id ge -1L")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmInt64Set?$filter=Id ge -1l")] + public async Task LongWithOrWithoutSuffixInFilterInURLTest(string mimeType, string filterQuery) + { + // Arrange & Act + var (resourceEntries, resourceSetEntries) = await TestsHelper.QueryResourceAndResourceSetsAsync(filterQuery, mimeType); + + // Assert + Assert.Equal(2, resourceEntries.Count); + + var entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmInt64Set(0)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmInt64Set(0)", entry.EditLink.ToString()); + Assert.EndsWith("EdmInt64Set(0)", entry.ReadLink.ToString()); + + entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmInt64Set(-1)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmInt64Set(-1)", entry.EditLink.ToString()); + Assert.EndsWith("EdmInt64Set(-1)", entry.ReadLink.ToString()); + + Assert.Single(resourceSetEntries); + + var feed = resourceSetEntries.SingleOrDefault(); + Assert.NotNull(feed); + Assert.EndsWith($"{filterQuery}&$skiptoken=Id-0", feed.NextPageLink.ToString()); + } + + [Theory] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmSingleSet?$filter=Id ge -1.0")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmSingleSet?$filter=Id ge -1.0F")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmSingleSet?$filter=Id ge -1.0f")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmSingleSet?$filter=Id ge -1.0")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmSingleSet?$filter=Id ge -1.0F")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmSingleSet?$filter=Id ge -1.0f")] + public async Task FloatWithOrWithoutSuffixInFilterInURLTest(string mimeType, string filterQuery) + { + // Arrange & Act & Assert + var (resourceEntries, resourceSetEntries) = await TestsHelper.QueryResourceAndResourceSetsAsync(filterQuery, mimeType); + + // Assert + Assert.Equal(2, resourceEntries.Count); + + var entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmSingleSet(0)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmSingleSet(0)", entry.EditLink.ToString()); + Assert.EndsWith("EdmSingleSet(0)", entry.ReadLink.ToString()); + + entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmSingleSet(-1)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmSingleSet(-1)", entry.EditLink.ToString()); + Assert.EndsWith("EdmSingleSet(-1)", entry.ReadLink.ToString()); + + Assert.Single(resourceSetEntries); + + var feed = resourceSetEntries.SingleOrDefault(); + Assert.NotNull(feed); + Assert.EndsWith($"{filterQuery}&$skiptoken=Id-0", feed.NextPageLink.ToString()); + } + + [Theory] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmDoubleSet?$filter=Id ge -1.0")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmDoubleSet?$filter=Id ge -1.0D")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmDoubleSet?$filter=Id ge -1.0d")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmDoubleSet?$filter=Id ge -1.0")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmDoubleSet?$filter=Id ge -1.0D")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmDoubleSet?$filter=Id ge -1.0d")] + public async Task DoubleWithOrWithoutSuffixInFilterInURLTest(string mimeType, string filterQuery) + { + // Arrange & Act + var (resourceEntries, resourceSetEntries) = await TestsHelper.QueryResourceAndResourceSetsAsync(filterQuery, mimeType); + + // Assert + Assert.Equal(2, resourceEntries.Count); + + var entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmDoubleSet(0.0)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmDoubleSet(0.0)", entry.EditLink.ToString()); + Assert.EndsWith("EdmDoubleSet(0.0)", entry.ReadLink.ToString()); + + entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmDoubleSet(-1.0)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmDoubleSet(-1.0)", entry.EditLink.ToString()); + Assert.EndsWith("EdmDoubleSet(-1.0)", entry.ReadLink.ToString()); + + Assert.Single(resourceSetEntries); + + var feed = resourceSetEntries.SingleOrDefault(); + Assert.NotNull(feed); + Assert.EndsWith($"{filterQuery}&$skiptoken=Id-0.0", feed.NextPageLink.ToString()); + } + + [Theory] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmDecimalSet?$filter=Id ge -1.0")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmDecimalSet?$filter=Id ge -1.0M")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmDecimalSet?$filter=Id ge -1.0m")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmDecimalSet?$filter=Id ge -1.0")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmDecimalSet?$filter=Id ge -1.0M")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmDecimalSet?$filter=Id ge -1.0m")] + public async Task DecimalWithOrWithoutSuffixInFilterInURLTest(string mimeType, string filterQuery) + { + // Arrange & Act + var (resourceEntries, resourceSetEntries) = await TestsHelper.QueryResourceAndResourceSetsAsync(filterQuery, mimeType); + + // Assert + Assert.Equal(2, resourceEntries.Count); + + var entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmDecimalSet(0)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmDecimalSet(0)", entry.EditLink.ToString()); + Assert.EndsWith("EdmDecimalSet(0)", entry.ReadLink.ToString()); + + entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmDecimalSet(-1)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmDecimalSet(-1)", entry.EditLink.ToString()); + Assert.EndsWith("EdmDecimalSet(-1)", entry.ReadLink.ToString()); + + Assert.Single(resourceSetEntries); + + var feed = resourceSetEntries.SingleOrDefault(); + Assert.NotNull(feed); + Assert.EndsWith($"{filterQuery}&$skiptoken=Id-0", feed.NextPageLink.ToString()); + } + + [Theory] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmInt64Set?$skiptoken=-1")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmInt64Set?$skiptoken=-1L")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmInt64Set?$skiptoken=-1l")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmInt64Set?$skiptoken=-1")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmInt64Set?$skiptoken=-1L")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmInt64Set?$skiptoken=-1l")] + public async Task LongWithOrWithoutSuffixInSkipTokenInURLTest(string mimeType, string skipTokenQuery) + { + // Arrange & Act + var (resourceEntries, resourceSetEntries) = await TestsHelper.QueryResourceAndResourceSetsAsync(skipTokenQuery, mimeType); + + // Assert + Assert.Equal(2, resourceEntries.Count); + + var entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmInt64Set(0)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmInt64Set(0)", entry.EditLink.ToString()); + Assert.EndsWith("EdmInt64Set(0)", entry.ReadLink.ToString()); + + entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmInt64Set(1)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmInt64Set(1)", entry.EditLink.ToString()); + Assert.EndsWith("EdmInt64Set(1)", entry.ReadLink.ToString()); + + Assert.Single(resourceSetEntries); + + var feed = resourceSetEntries.SingleOrDefault(); + Assert.NotNull(feed); + Assert.EndsWith("EdmInt64Set?$skiptoken=Id-1", feed.NextPageLink.ToString()); + } + + [Theory] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmSingleSet?$skiptoken=-1.0")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmSingleSet?$skiptoken=-1.0F")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmSingleSet?$skiptoken=-1.0f")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmSingleSet?$skiptoken=-1.0")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmSingleSet?$skiptoken=-1.0F")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmSingleSet?$skiptoken=-1.0f")] + public async Task FloatWithOrWithoutSuffixInSkipTokenInURLTest(string mimeType, string skipTokenQuery) + { + // Arrange & Act + var (resourceEntries, resourceSetEntries) = await TestsHelper.QueryResourceAndResourceSetsAsync(skipTokenQuery, mimeType); + + // Assert + Assert.Equal(2, resourceEntries.Count); + + var entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmSingleSet(0)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmSingleSet(0)", entry.EditLink.ToString()); + Assert.EndsWith("EdmSingleSet(0)", entry.ReadLink.ToString()); + + entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmSingleSet(1E-45)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmSingleSet(1E-45)", entry.EditLink.ToString()); + Assert.EndsWith("EdmSingleSet(1E-45)", entry.ReadLink.ToString()); + + Assert.Single(resourceSetEntries); + + var feed = resourceSetEntries.SingleOrDefault(); + Assert.NotNull(feed); + Assert.EndsWith("EdmSingleSet?$skiptoken=Id-1E-45", feed.NextPageLink.ToString()); + } + + [Theory] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmDoubleSet?$skiptoken=-1.0")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmDoubleSet?$skiptoken=-1.0D")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmDoubleSet?$skiptoken=-1.0d")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmDoubleSet?$skiptoken=-1.0")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmDoubleSet?$skiptoken=-1.0D")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmDoubleSet?$skiptoken=-1.0d")] + public async Task DoubleWithOrWithoutSuffixInSkipTokenInURLTest(string mimeType, string skipTokenQuery) + { + // Arrange & Act + var (resourceEntries, resourceSetEntries) = await TestsHelper.QueryResourceAndResourceSetsAsync(skipTokenQuery, mimeType); + + // Assert + Assert.Equal(2, resourceEntries.Count); + + var entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmDoubleSet(0.0)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmDoubleSet(0.0)", entry.EditLink.ToString()); + Assert.EndsWith("EdmDoubleSet(0.0)", entry.ReadLink.ToString()); + + entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmDoubleSet(5E-324)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmDoubleSet(5E-324)", entry.EditLink.ToString()); + Assert.EndsWith("EdmDoubleSet(5E-324)", entry.ReadLink.ToString()); + + Assert.Single(resourceSetEntries); + + var feed = resourceSetEntries.SingleOrDefault(); + Assert.NotNull(feed); + Assert.EndsWith("EdmDoubleSet?$skiptoken=Id-5E-324", feed.NextPageLink.ToString()); + } + + [Theory] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmDecimalSet?$skiptoken=-1.0")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmDecimalSet?$skiptoken=-1.0M")] + [InlineData(MimeTypeODataParameterFullMetadata, "EdmDecimalSet?$skiptoken=-1.0m")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmDecimalSet?$skiptoken=-1.0")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmDecimalSet?$skiptoken=-1.0M")] + [InlineData(MimeTypeODataParameterFullMetadataAndIEEE754Compatible, "EdmDecimalSet?$skiptoken=-1.0m")] + public async Task DecimalWithSuffixInSkipTokenInURLTest(string mimeType, string skipTokenQuery) + { + // Arrange & Act + var (resourceEntries, resourceSetEntries) = await TestsHelper.QueryResourceAndResourceSetsAsync(skipTokenQuery, mimeType); + + // Assert + Assert.Equal(2, resourceEntries.Count); + + var entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmDecimalSet(0)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmDecimalSet(0)", entry.EditLink.ToString()); + Assert.EndsWith("EdmDecimalSet(0)", entry.ReadLink.ToString()); + + entry = resourceEntries.SingleOrDefault(e => e.Id.ToString().EndsWith("EdmDecimalSet(1)")); + Assert.NotNull(entry); + Assert.EndsWith("EdmDecimalSet(1)", entry.EditLink.ToString()); + Assert.EndsWith("EdmDecimalSet(1)", entry.ReadLink.ToString()); + + Assert.Single(resourceSetEntries); + + var feed = resourceSetEntries.SingleOrDefault(); + Assert.NotNull(feed); + Assert.EndsWith("EdmDecimalSet?$skiptoken=Id-1", feed.NextPageLink.ToString()); + } + + #region Client Tests + + [Fact] + public async Task LongInFilterLinqQueryTest() + { + // Arrange + const long int64Id = 1; + + // Act & Assert + var query = _context.CreateQuery("EdmInt64Set").Where(e => e.Id >= int64Id) as DataServiceQuery; + Assert.NotNull(query); + var int64QueryResult = await query.ExecuteAsync(); + Assert.NotNull(int64QueryResult); + Assert.True(int64QueryResult.Count() > 0, "Expected one or more EdmInt64 entities could be returned "); + + query = (from c in _context.EdmInt64Set where c.Id >= int64Id select c) as DataServiceQuery; + Assert.NotNull(query); + int64QueryResult = await query.ExecuteAsync(); + Assert.NotNull(int64QueryResult); + Assert.True(int64QueryResult.Count() > 0, "Expected one or more EdmInt64 entities could be returned "); + + var anotherQuery = _context.CreateQuery("EdmInt64Set").Where(e => e.Id == int64Id); + int count = 0; + foreach (var int64 in anotherQuery) + { + count++; + } + + Assert.True(count == 1, "Expected one or more EdmInt64 entities could be returned "); + + var byKeyInt64QueryResult = await _context.EdmInt64Set.ByKey(new Dictionary { { "Id", int64Id } }).GetValueAsync(); + Assert.True(byKeyInt64QueryResult.Id == 1, "Expected one or more EdmInt64 entities could be returned "); + } + + [Fact] + public async Task FloatInFilterLinqQueryTest() + { + // Arrange + const float floatId = 1.0f; + + // Act & Assert + var query = _context.CreateQuery("EdmSingleSet").Where(e => e.Id >= floatId) as DataServiceQuery; + Assert.NotNull(query); + var floatQueryResult = await query.ExecuteAsync(); + Assert.True(floatQueryResult.Count() > 0, "Expected one or more EdmSingle entities could be returned"); + + query = (from c in _context.EdmSingleSet where c.Id >= floatId select c) as DataServiceQuery; + Assert.NotNull(query); + floatQueryResult = await query.ExecuteAsync(); + Assert.True(floatQueryResult.Count() > 0, "Expected one or more EdmSingle entities could be returned"); + + } + + [Fact] + public async Task DoubleInFilterLinqQueryTest() + { + // Arrange + const double doubleId = 1.0; + + // Act & Assert + var query = _context.CreateQuery("EdmDoubleSet").Where(e => e.Id >= doubleId) as DataServiceQuery; + Assert.NotNull(query); + var doubleQueryResult = await query.ExecuteAsync(); + Assert.True(doubleQueryResult.Count() > 0, "Expected one or more EdmDouble entities could be returned"); + + query = (from c in _context.EdmDoubleSet where c.Id >= doubleId select c) as DataServiceQuery; + Assert.NotNull(query); + doubleQueryResult = await query.ExecuteAsync(); + Assert.True(doubleQueryResult.Count() > 0, "Expected one or more EdmDouble.MaxValue could be returned"); + } + + [Fact] + public async Task DecimalInFilterLinqQueryTest() + { + // Arrange + const decimal decimalId = 1.0M; + + // Act & Assert + var query = _context.CreateQuery("EdmDecimalSet").Where(e => e.Id >= decimalId) as DataServiceQuery; + Assert.NotNull(query); + var decimalQueryResult = await query.ExecuteAsync(); + Assert.True(decimalQueryResult.Count() > 0, "Expected one or more EdmDecimal entities could be returned"); + + query = (from c in _context.EdmDecimalSet where c.Id >= decimalId select c) as DataServiceQuery; + Assert.NotNull(query); + decimalQueryResult = await query.ExecuteAsync(); + Assert.True(decimalQueryResult.Count() > 0, "Expected one or more EdmDecimal entities could be returned"); + } + + #endregion + + #region Private methods + + private PrimitiveTypesTestsHelper TestsHelper + { + get + { + return new PrimitiveTypesTestsHelper(_baseUri, _model, Client); + } + } + + private void ResetDefaultDataSource() + { + var actionUri = new Uri(_baseUri + "primitivekeyvalues/Default.ResetDefaultDataSource", UriKind.Absolute); + _context.Execute(actionUri, "POST"); + } + + #endregion +}