├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md ├── .gitignore ├── AspNetOdata.sln ├── AspNetOdata ├── AspNetOdata.csproj ├── Controllers │ ├── ProductController.cs │ └── WeatherForecastController.cs ├── Data │ └── Class.cs ├── Models │ ├── Configurations │ │ ├── BrandConfiguration.cs │ │ └── ProductConfiguration.cs │ ├── EClinicContext.cs │ └── dbo │ │ ├── Brand.cs │ │ └── Product.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── WeatherForecast.cs ├── appsettings.Development.json ├── appsettings.json └── efpt.config.json ├── BlazorAppOdataClient ├── App.razor ├── BlazorAppOdataClient.csproj ├── Layout │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ └── NavMenu.razor.css ├── Model │ └── Product.cs ├── Pages │ ├── Counter.razor │ ├── Home.razor │ ├── Home.razor.cs │ └── Weather.razor ├── Program.cs ├── Properties │ └── launchSettings.json ├── _Imports.razor └── wwwroot │ ├── css │ ├── app.css │ └── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ ├── favicon.png │ ├── icon-192.png │ ├── icon-512.png │ ├── index.html │ ├── manifest.webmanifest │ ├── sample-data │ └── weather.json │ ├── service-worker.js │ └── service-worker.published.js ├── CODE_OF_CONDUCT.md ├── ConsoleConsumer ├── Brand.cs ├── ConsoleConsumer.csproj ├── Product.cs └── Program.cs ├── LICENSE ├── README.md └── SECURITY.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /AspNetOdata.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34322.80 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetOdata", "AspNetOdata\AspNetOdata.csproj", "{63BECE66-4C16-4C52-BA1B-66D730417EE0}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleConsumer", "ConsoleConsumer\ConsoleConsumer.csproj", "{1EBB1125-0866-42F9-94EC-3C1A52B2DF69}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorAppOdataClient", "BlazorAppOdataClient\BlazorAppOdataClient.csproj", "{F86576E3-390D-4061-9A5A-494E38E80EC8}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {63BECE66-4C16-4C52-BA1B-66D730417EE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {63BECE66-4C16-4C52-BA1B-66D730417EE0}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {63BECE66-4C16-4C52-BA1B-66D730417EE0}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {63BECE66-4C16-4C52-BA1B-66D730417EE0}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {1EBB1125-0866-42F9-94EC-3C1A52B2DF69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {1EBB1125-0866-42F9-94EC-3C1A52B2DF69}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {1EBB1125-0866-42F9-94EC-3C1A52B2DF69}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {1EBB1125-0866-42F9-94EC-3C1A52B2DF69}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {F86576E3-390D-4061-9A5A-494E38E80EC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {F86576E3-390D-4061-9A5A-494E38E80EC8}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {F86576E3-390D-4061-9A5A-494E38E80EC8}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {F86576E3-390D-4061-9A5A-494E38E80EC8}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {5B4B5E98-F6D1-43A6-A09D-373D7E7581D5} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /AspNetOdata/AspNetOdata.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | all 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /AspNetOdata/Controllers/ProductController.cs: -------------------------------------------------------------------------------- 1 | using AspNetOdata.Models; 2 | 3 | using Microsoft.AspNet.OData.Routing; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.AspNetCore.OData.Formatter; 6 | using Microsoft.AspNetCore.OData.Query; 7 | using Microsoft.AspNetCore.OData.Results; 8 | using Microsoft.AspNetCore.OData.Routing.Controllers; 9 | 10 | namespace AspNetOdata.Controllers 11 | { 12 | 13 | public class ProductController : ODataController 14 | { 15 | protected readonly EClinicContext _eClinicContext; 16 | 17 | public ProductController(EClinicContext eClinicContext) 18 | { 19 | _eClinicContext = eClinicContext; 20 | } 21 | 22 | 23 | [EnableQuery] 24 | [HttpGet] 25 | public IActionResult Get() 26 | { 27 | return Ok(_eClinicContext.Products.AsQueryable()); 28 | } 29 | 30 | [ODataRoute("({key})")] 31 | [EnableQuery] 32 | public virtual SingleResult Get([FromODataUri] int key) 33 | { 34 | return SingleResult.Create(_eClinicContext.Set().Where(x=>x.Id == key).AsQueryable()); 35 | } 36 | 37 | [HttpPost] 38 | public async Task> Post([FromBody]Product product) 39 | { 40 | _eClinicContext.Products.Add(product); 41 | 42 | await _eClinicContext.SaveChangesAsync(); 43 | 44 | return CreatedAtAction("Get", new { id = product.Id }, product); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /AspNetOdata/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace AspNetOdata.Controllers 4 | { 5 | [ApiController] 6 | [Route("[controller]")] 7 | public class WeatherForecastController : ControllerBase 8 | { 9 | private static readonly string[] Summaries = new[] 10 | { 11 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 12 | }; 13 | 14 | private readonly ILogger _logger; 15 | 16 | public WeatherForecastController(ILogger logger) 17 | { 18 | _logger = logger; 19 | } 20 | 21 | [HttpGet(Name = "GetWeatherForecast")] 22 | public IEnumerable Get() 23 | { 24 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 25 | { 26 | Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), 27 | TemperatureC = Random.Shared.Next(-20, 55), 28 | Summary = Summaries[Random.Shared.Next(Summaries.Length)] 29 | }) 30 | .ToArray(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /AspNetOdata/Data/Class.cs: -------------------------------------------------------------------------------- 1 | using AspNetOdata.Models; 2 | 3 | using Microsoft.OData.Edm; 4 | using Microsoft.OData.ModelBuilder; 5 | 6 | namespace AspNetOdata.Data 7 | { 8 | internal static class EdmModel 9 | { 10 | public static IEdmModel GetEdmModel() 11 | { 12 | ODataConventionModelBuilder builder = new(); 13 | 14 | builder.EntitySet("Product"); 15 | 16 | 17 | return builder.GetEdmModel(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /AspNetOdata/Models/Configurations/BrandConfiguration.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using AspNetOdata.Models; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | namespace AspNetOdata.Models.Configurations 9 | { 10 | public partial class BrandConfiguration : IEntityTypeConfiguration 11 | { 12 | public void Configure(EntityTypeBuilder entity) 13 | { 14 | entity.Property(e => e.Tax).HasColumnType("decimal(18, 2)"); 15 | 16 | OnConfigurePartial(entity); 17 | } 18 | 19 | partial void OnConfigurePartial(EntityTypeBuilder entity); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /AspNetOdata/Models/Configurations/ProductConfiguration.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using AspNetOdata.Models; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | namespace AspNetOdata.Models.Configurations 9 | { 10 | public partial class ProductConfiguration : IEntityTypeConfiguration 11 | { 12 | public void Configure(EntityTypeBuilder entity) 13 | { 14 | entity.HasIndex(e => e.BrandId, "IX_Products_BrandId"); 15 | 16 | entity.Property(e => e.ImageDataUrl) 17 | .HasColumnType("text") 18 | .HasColumnName("ImageDataURL"); 19 | entity.Property(e => e.Rate).HasColumnType("decimal(18, 2)"); 20 | 21 | entity.HasOne(d => d.Brand).WithMany(p => p.Products).HasForeignKey(d => d.BrandId); 22 | 23 | OnConfigurePartial(entity); 24 | } 25 | 26 | partial void OnConfigurePartial(EntityTypeBuilder entity); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /AspNetOdata/Models/EClinicContext.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using Microsoft.EntityFrameworkCore; 3 | #nullable disable 4 | 5 | namespace AspNetOdata.Models; 6 | 7 | public partial class EClinicContext : DbContext 8 | { 9 | public EClinicContext(DbContextOptions options) 10 | : base(options) 11 | { 12 | } 13 | 14 | public virtual DbSet Brands { get; set; } 15 | 16 | public virtual DbSet Products { get; set; } 17 | 18 | protected override void OnModelCreating(ModelBuilder modelBuilder) 19 | { 20 | modelBuilder.ApplyConfiguration(new Configurations.BrandConfiguration()); 21 | modelBuilder.ApplyConfiguration(new Configurations.ProductConfiguration()); 22 | 23 | OnModelCreatingPartial(modelBuilder); 24 | } 25 | 26 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder); 27 | } 28 | -------------------------------------------------------------------------------- /AspNetOdata/Models/dbo/Brand.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | #nullable disable 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace AspNetOdata.Models; 7 | 8 | public partial class Brand 9 | { 10 | public int Id { get; set; } 11 | 12 | public string Name { get; set; } 13 | 14 | public string Description { get; set; } 15 | 16 | public decimal Tax { get; set; } 17 | 18 | public string CreatedBy { get; set; } 19 | 20 | public DateTime CreatedOn { get; set; } 21 | 22 | public string LastModifiedBy { get; set; } 23 | 24 | public DateTime? LastModifiedOn { get; set; } 25 | 26 | public virtual ICollection Products { get; set; } = new List(); 27 | } -------------------------------------------------------------------------------- /AspNetOdata/Models/dbo/Product.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | #nullable disable 3 | 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text.Json.Serialization; 8 | 9 | namespace AspNetOdata.Models; 10 | 11 | public partial class Product 12 | { 13 | public int Id { get; set; } 14 | 15 | public string Name { get; set; } 16 | 17 | public string Barcode { get; set; } 18 | 19 | public string ImageDataUrl { get; set; } 20 | 21 | public string Description { get; set; } 22 | 23 | public decimal Rate { get; set; } 24 | 25 | public int BrandId { get; set; } 26 | 27 | [JsonIgnore] 28 | public string CreatedBy { get; set; } = Guid.NewGuid().ToString(); 29 | [JsonIgnore] 30 | public DateTime CreatedOn { get; set; } = DateTime.UtcNow; 31 | [JsonIgnore] 32 | public string LastModifiedBy { get; set; } = Guid.NewGuid().ToString(); 33 | [JsonIgnore] 34 | public DateTime? LastModifiedOn { get; set; } = DateTime.UtcNow; 35 | 36 | public virtual Brand Brand { get; set; } 37 | } -------------------------------------------------------------------------------- /AspNetOdata/Program.cs: -------------------------------------------------------------------------------- 1 | using AspNetOdata.Data; 2 | using AspNetOdata.Models; 3 | 4 | using Microsoft.AspNetCore.OData; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.Extensions.Configuration; 7 | 8 | var builder = WebApplication.CreateBuilder(args); 9 | 10 | // Add services to the container. 11 | 12 | builder.Services.AddControllers(); 13 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle 14 | builder.Services.AddEndpointsApiExplorer(); 15 | builder.Services.AddSwaggerGen(); 16 | 17 | 18 | builder.Services.AddCors(policy => 19 | { 20 | policy.AddPolicy("CorsPolicy", opt => opt 21 | .AllowAnyOrigin() 22 | .AllowAnyHeader() 23 | .AllowAnyMethod()); 24 | }); 25 | 26 | builder.Services.AddControllers() 27 | .AddOData(options => options 28 | .AddRouteComponents("odata", EdmModel.GetEdmModel()) 29 | .Select() 30 | .Filter() 31 | .OrderBy() 32 | .SetMaxTop(200) 33 | .Count() 34 | .Expand() 35 | ); 36 | builder.Services.AddDbContextPool((serviceProvider, optionsBuilder) => 37 | { 38 | optionsBuilder.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"), 39 | sqlServerOptionsAction: sqlOptions => 40 | { 41 | sqlOptions.EnableRetryOnFailure( 42 | maxRetryCount: 10, 43 | maxRetryDelay: TimeSpan.FromSeconds(30), 44 | errorNumbersToAdd: null); 45 | sqlOptions.CommandTimeout(300); 46 | 47 | }).UseQueryTrackingBehavior(QueryTrackingBehavior.TrackAll); 48 | }); 49 | 50 | var app = builder.Build(); 51 | 52 | // Configure the HTTP request pipeline. 53 | if (app.Environment.IsDevelopment()) 54 | { 55 | app.UseSwagger(); 56 | app.UseSwaggerUI(); 57 | } 58 | 59 | app.UseHttpsRedirection(); 60 | 61 | app.UseAuthorization(); 62 | 63 | app.MapControllers(); 64 | 65 | app.UseCors("CorsPolicy"); 66 | 67 | app.Run(); 68 | -------------------------------------------------------------------------------- /AspNetOdata/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:24109", 8 | "sslPort": 44361 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "launchUrl": "swagger", 17 | "applicationUrl": "http://localhost:5266", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "https": { 23 | "commandName": "Project", 24 | "dotnetRunMessages": true, 25 | "launchBrowser": true, 26 | "launchUrl": "swagger", 27 | "applicationUrl": "https://localhost:7003;http://localhost:5266", 28 | "environmentVariables": { 29 | "ASPNETCORE_ENVIRONMENT": "Development" 30 | } 31 | }, 32 | "IIS Express": { 33 | "commandName": "IISExpress", 34 | "launchBrowser": true, 35 | "launchUrl": "swagger", 36 | "environmentVariables": { 37 | "ASPNETCORE_ENVIRONMENT": "Development" 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /AspNetOdata/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | namespace AspNetOdata 2 | { 3 | public class WeatherForecast 4 | { 5 | public DateOnly Date { get; set; } 6 | 7 | public int TemperatureC { get; set; } 8 | 9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 10 | 11 | public string? Summary { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /AspNetOdata/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /AspNetOdata/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "DefaultConnection": "Data Source=.;Initial Catalog=GymAppDb;Integrated Security=True;MultipleActiveResultSets=True;TrustServerCertificate=true;" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /AspNetOdata/efpt.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "CodeGenerationMode": 3, 3 | "ContextClassName": "E-ClinicContext", 4 | "ContextNamespace": null, 5 | "DefaultDacpacSchema": null, 6 | "FilterSchemas": false, 7 | "IncludeConnectionString": false, 8 | "ModelNamespace": null, 9 | "OutputContextPath": null, 10 | "OutputPath": "Models", 11 | "PreserveCasingWithRegex": true, 12 | "ProjectRootNamespace": "AspNetOdata", 13 | "Schemas": null, 14 | "SelectedHandlebarsLanguage": 2, 15 | "SelectedToBeGenerated": 0, 16 | "T4TemplatePath": null, 17 | "Tables": [ 18 | { 19 | "Name": "[dbo].[Brands]", 20 | "ObjectType": 0 21 | }, 22 | { 23 | "Name": "[dbo].[Products]", 24 | "ObjectType": 0 25 | } 26 | ], 27 | "UiHint": "spyros.E-Clinic.dbo", 28 | "UncountableWords": null, 29 | "UseBoolPropertiesWithoutDefaultSql": false, 30 | "UseDatabaseNames": false, 31 | "UseDateOnlyTimeOnly": false, 32 | "UseDbContextSplitting": true, 33 | "UseDecimalDataAnnotationForSprocResult": true, 34 | "UseFluentApiOnly": true, 35 | "UseHandleBars": false, 36 | "UseHierarchyId": false, 37 | "UseInflector": true, 38 | "UseLegacyPluralizer": false, 39 | "UseManyToManyEntity": false, 40 | "UseNoDefaultConstructor": false, 41 | "UseNoNavigations": false, 42 | "UseNoObjectFilter": false, 43 | "UseNodaTime": false, 44 | "UseNullableReferences": false, 45 | "UseSchemaFolders": true, 46 | "UseSchemaNamespaces": false, 47 | "UseSpatial": false, 48 | "UseT4": false 49 | } -------------------------------------------------------------------------------- /BlazorAppOdataClient/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Not found 8 | 9 |

Sorry, there's nothing at this address.

10 |
11 |
12 |
13 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/BlazorAppOdataClient.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | service-worker-assets.js 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 |
3 | 6 | 7 |
8 |
9 | About 10 |
11 | 12 |
13 | @Body 14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/Layout/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row ::deep .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | text-decoration: none; 28 | } 29 | 30 | .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { 31 | text-decoration: underline; 32 | } 33 | 34 | .top-row ::deep a:first-child { 35 | overflow: hidden; 36 | text-overflow: ellipsis; 37 | } 38 | 39 | @media (max-width: 640.98px) { 40 | .top-row { 41 | justify-content: space-between; 42 | } 43 | 44 | .top-row ::deep a, .top-row ::deep .btn-link { 45 | margin-left: 0; 46 | } 47 | } 48 | 49 | @media (min-width: 641px) { 50 | .page { 51 | flex-direction: row; 52 | } 53 | 54 | .sidebar { 55 | width: 250px; 56 | height: 100vh; 57 | position: sticky; 58 | top: 0; 59 | } 60 | 61 | .top-row { 62 | position: sticky; 63 | top: 0; 64 | z-index: 1; 65 | } 66 | 67 | .top-row.auth ::deep a:first-child { 68 | flex: 1; 69 | text-align: right; 70 | width: 0; 71 | } 72 | 73 | .top-row, article { 74 | padding-left: 2rem !important; 75 | padding-right: 1.5rem !important; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  9 | 10 | 29 | 30 | @code { 31 | private bool collapseNavMenu = true; 32 | 33 | private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; 34 | 35 | private void ToggleNavMenu() 36 | { 37 | collapseNavMenu = !collapseNavMenu; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/Layout/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .bi { 15 | display: inline-block; 16 | position: relative; 17 | width: 1.25rem; 18 | height: 1.25rem; 19 | margin-right: 0.75rem; 20 | top: -1px; 21 | background-size: cover; 22 | } 23 | 24 | .bi-house-door-fill-nav-menu { 25 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E"); 26 | } 27 | 28 | .bi-plus-square-fill-nav-menu { 29 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E"); 30 | } 31 | 32 | .bi-list-nested-nav-menu { 33 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E"); 34 | } 35 | 36 | .nav-item { 37 | font-size: 0.9rem; 38 | padding-bottom: 0.5rem; 39 | } 40 | 41 | .nav-item:first-of-type { 42 | padding-top: 1rem; 43 | } 44 | 45 | .nav-item:last-of-type { 46 | padding-bottom: 1rem; 47 | } 48 | 49 | .nav-item ::deep a { 50 | color: #d7d7d7; 51 | border-radius: 4px; 52 | height: 3rem; 53 | display: flex; 54 | align-items: center; 55 | line-height: 3rem; 56 | } 57 | 58 | .nav-item ::deep a.active { 59 | background-color: rgba(255,255,255,0.37); 60 | color: white; 61 | } 62 | 63 | .nav-item ::deep a:hover { 64 | background-color: rgba(255,255,255,0.1); 65 | color: white; 66 | } 67 | 68 | @media (min-width: 641px) { 69 | .navbar-toggler { 70 | display: none; 71 | } 72 | 73 | .collapse { 74 | /* Never collapse the sidebar for wide screens */ 75 | display: block; 76 | } 77 | 78 | .nav-scrollable { 79 | /* Allow sidebar to scroll for tall menus */ 80 | height: calc(100vh - 3.5rem); 81 | overflow-y: auto; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/Model/Product.cs: -------------------------------------------------------------------------------- 1 |  2 | 3 | using System.Text.Json.Serialization; 4 | 5 | public class Product 6 | { 7 | public int Id { get; set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public string Barcode { get; set; } 12 | 13 | public string ImageDataUrl { get; set; } 14 | 15 | public string Description { get; set; } 16 | 17 | public decimal Rate { get; set; } 18 | 19 | public int BrandId { get; set; } 20 | 21 | [JsonIgnore] 22 | public string CreatedBy { get; set; } 23 | [JsonIgnore] 24 | public DateTime CreatedOn { get; set; } 25 | [JsonIgnore] 26 | public string LastModifiedBy { get; set; } 27 | [JsonIgnore] 28 | public DateTime? LastModifiedOn { get; set; } 29 | 30 | public virtual Brand Brand { get; set; } 31 | } 32 | 33 | 34 | public class Brand 35 | { 36 | public int Id { get; set; } 37 | 38 | public string Name { get; set; } 39 | 40 | public string Description { get; set; } 41 | 42 | public decimal Tax { get; set; } 43 | 44 | [JsonIgnore] 45 | public string CreatedBy { get; set; } 46 | [JsonIgnore] 47 | public DateTime CreatedOn { get; set; } 48 | [JsonIgnore] 49 | public string LastModifiedBy { get; set; } 50 | [JsonIgnore] 51 | public DateTime? LastModifiedOn { get; set; } 52 | 53 | public virtual ICollection Products { get; set; } = new List(); 54 | } -------------------------------------------------------------------------------- /BlazorAppOdataClient/Pages/Counter.razor: -------------------------------------------------------------------------------- 1 | @page "/counter" 2 | 3 | Counter 4 | 5 |

Counter

6 | 7 |

Current count: @currentCount

8 | 9 | 10 | 11 | @code { 12 | private int currentCount = 0; 13 | 14 | private void IncrementCount() 15 | { 16 | currentCount++; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Testing Odata With Blazor 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | @if (products == null) 18 | { 19 |

Loading...

20 | } 21 | else 22 | { 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | @foreach (var product in products) 33 | { 34 | 35 | 36 | 37 | 38 | 39 | } 40 | 41 |
NameDescriptionBrand
@product.Name@product.Description@product.Brand.Name
42 | } -------------------------------------------------------------------------------- /BlazorAppOdataClient/Pages/Home.razor.cs: -------------------------------------------------------------------------------- 1 | using Simple.OData.Client; 2 | 3 | namespace BlazorAppOdataClient.Pages 4 | { 5 | public partial class Home 6 | { 7 | protected ODataClient client = new ODataClient("https://localhost:7003/odata/"); 8 | protected IEnumerable products; 9 | 10 | protected string errorMessage = string.Empty; 11 | 12 | private async Task GetData() 13 | { 14 | try 15 | { 16 | products = await client 17 | .For() 18 | .Expand(x => x.Brand) 19 | .FindEntriesAsync(); 20 | 21 | } 22 | catch (Exception ex) 23 | { 24 | errorMessage = string.Empty; 25 | 26 | errorMessage = ex.Message; 27 | 28 | Console.WriteLine(ex.Message); 29 | } 30 | 31 | } 32 | 33 | private async Task GetDataWithId() 34 | { 35 | try 36 | { 37 | var product = await client 38 | .For() 39 | .Key(1) 40 | .Expand(x => x.Brand) 41 | .FindEntryAsync(); 42 | 43 | 44 | await this.GetData(); 45 | 46 | } 47 | catch (Exception ex) 48 | { 49 | errorMessage = string.Empty; 50 | 51 | errorMessage = ex.Message; 52 | 53 | Console.WriteLine(ex.Message); 54 | } 55 | 56 | } 57 | 58 | private async Task CreateProduct() 59 | { 60 | try 61 | { 62 | var product = await client 63 | .For() 64 | .Set(new 65 | { 66 | Barcode = "Test", 67 | Description = "Test", 68 | ImageDataUrl = "Test", 69 | Name = "Test", 70 | Rate = 1, 71 | BrandId = 1 72 | }) 73 | .InsertEntryAsync(); 74 | 75 | await this.GetData(); 76 | 77 | } 78 | catch (Exception ex) 79 | { 80 | errorMessage = string.Empty; 81 | 82 | errorMessage = ex.Message; 83 | 84 | Console.WriteLine(ex.Message); 85 | } 86 | 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/Pages/Weather.razor: -------------------------------------------------------------------------------- 1 | @page "/weather" 2 | @inject HttpClient Http 3 | 4 | Weather 5 | 6 |

Weather

7 | 8 |

This component demonstrates fetching data from the server.

9 | 10 | @if (forecasts == null) 11 | { 12 |

Loading...

13 | } 14 | else 15 | { 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | @foreach (var forecast in forecasts) 27 | { 28 | 29 | 30 | 31 | 32 | 33 | 34 | } 35 | 36 |
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
37 | } 38 | 39 | @code { 40 | private WeatherForecast[]? forecasts; 41 | 42 | protected override async Task OnInitializedAsync() 43 | { 44 | forecasts = await Http.GetFromJsonAsync("sample-data/weather.json"); 45 | } 46 | 47 | public class WeatherForecast 48 | { 49 | public DateOnly Date { get; set; } 50 | 51 | public int TemperatureC { get; set; } 52 | 53 | public string? Summary { get; set; } 54 | 55 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/Program.cs: -------------------------------------------------------------------------------- 1 | using BlazorAppOdataClient; 2 | 3 | using Microsoft.AspNetCore.Components.Web; 4 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 5 | 6 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 7 | builder.RootComponents.Add("#app"); 8 | builder.RootComponents.Add("head::after"); 9 | 10 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7003/") }); 11 | 12 | await builder.Build().RunAsync(); 13 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:41036", 8 | "sslPort": 44331 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 17 | "applicationUrl": "http://localhost:5098", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "https": { 23 | "commandName": "Project", 24 | "dotnetRunMessages": true, 25 | "launchBrowser": true, 26 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 27 | "applicationUrl": "https://localhost:7018;http://localhost:5098", 28 | "environmentVariables": { 29 | "ASPNETCORE_ENVIRONMENT": "Development" 30 | } 31 | }, 32 | "IIS Express": { 33 | "commandName": "IISExpress", 34 | "launchBrowser": true, 35 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 36 | "environmentVariables": { 37 | "ASPNETCORE_ENVIRONMENT": "Development" 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using BlazorAppOdataClient 10 | @using BlazorAppOdataClient.Layout 11 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 3 | } 4 | 5 | h1:focus { 6 | outline: none; 7 | } 8 | 9 | a, .btn-link { 10 | color: #0071c1; 11 | } 12 | 13 | .btn-primary { 14 | color: #fff; 15 | background-color: #1b6ec2; 16 | border-color: #1861ac; 17 | } 18 | 19 | .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { 20 | box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; 21 | } 22 | 23 | .content { 24 | padding-top: 1.1rem; 25 | } 26 | 27 | .valid.modified:not([type=checkbox]) { 28 | outline: 1px solid #26b050; 29 | } 30 | 31 | .invalid { 32 | outline: 1px solid red; 33 | } 34 | 35 | .validation-message { 36 | color: red; 37 | } 38 | 39 | #blazor-error-ui { 40 | background: lightyellow; 41 | bottom: 0; 42 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 43 | display: none; 44 | left: 0; 45 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 46 | position: fixed; 47 | width: 100%; 48 | z-index: 1000; 49 | } 50 | 51 | #blazor-error-ui .dismiss { 52 | cursor: pointer; 53 | position: absolute; 54 | right: 0.75rem; 55 | top: 0.5rem; 56 | } 57 | 58 | .blazor-error-boundary { 59 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 60 | padding: 1rem 1rem 1rem 3.7rem; 61 | color: white; 62 | } 63 | 64 | .blazor-error-boundary::after { 65 | content: "An error has occurred." 66 | } 67 | 68 | .loading-progress { 69 | position: relative; 70 | display: block; 71 | width: 8rem; 72 | height: 8rem; 73 | margin: 20vh auto 1rem auto; 74 | } 75 | 76 | .loading-progress circle { 77 | fill: none; 78 | stroke: #e0e0e0; 79 | stroke-width: 0.6rem; 80 | transform-origin: 50% 50%; 81 | transform: rotate(-90deg); 82 | } 83 | 84 | .loading-progress circle:last-child { 85 | stroke: #1b6ec2; 86 | stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; 87 | transition: stroke-dasharray 0.05s ease-in-out; 88 | } 89 | 90 | .loading-progress-text { 91 | position: absolute; 92 | text-align: center; 93 | font-weight: bold; 94 | inset: calc(20vh + 3.25rem) 0 auto 0.2rem; 95 | } 96 | 97 | .loading-progress-text:after { 98 | content: var(--blazor-load-percentage-text, "Loading"); 99 | } 100 | 101 | code { 102 | color: #c02d76; 103 | } 104 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevsharp/AspNetOdata/1cf03e473ad4e1b47e0289b129f44dc7c2e4fa0f/BlazorAppOdataClient/wwwroot/favicon.png -------------------------------------------------------------------------------- /BlazorAppOdataClient/wwwroot/icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevsharp/AspNetOdata/1cf03e473ad4e1b47e0289b129f44dc7c2e4fa0f/BlazorAppOdataClient/wwwroot/icon-192.png -------------------------------------------------------------------------------- /BlazorAppOdataClient/wwwroot/icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevsharp/AspNetOdata/1cf03e473ad4e1b47e0289b129f44dc7c2e4fa0f/BlazorAppOdataClient/wwwroot/icon-512.png -------------------------------------------------------------------------------- /BlazorAppOdataClient/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | BlazorAppOdataClient 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 |
25 |
26 | 27 |
28 | An unhandled error has occurred. 29 | Reload 30 | 🗙 31 |
32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/wwwroot/manifest.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BlazorAppOdataClient", 3 | "short_name": "BlazorAppOdataClient", 4 | "id": "./", 5 | "start_url": "./", 6 | "display": "standalone", 7 | "background_color": "#ffffff", 8 | "theme_color": "#03173d", 9 | "prefer_related_applications": false, 10 | "icons": [ 11 | { 12 | "src": "icon-512.png", 13 | "type": "image/png", 14 | "sizes": "512x512" 15 | }, 16 | { 17 | "src": "icon-192.png", 18 | "type": "image/png", 19 | "sizes": "192x192" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/wwwroot/sample-data/weather.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "date": "2022-01-06", 4 | "temperatureC": 1, 5 | "summary": "Freezing" 6 | }, 7 | { 8 | "date": "2022-01-07", 9 | "temperatureC": 14, 10 | "summary": "Bracing" 11 | }, 12 | { 13 | "date": "2022-01-08", 14 | "temperatureC": -13, 15 | "summary": "Freezing" 16 | }, 17 | { 18 | "date": "2022-01-09", 19 | "temperatureC": -16, 20 | "summary": "Balmy" 21 | }, 22 | { 23 | "date": "2022-01-10", 24 | "temperatureC": -2, 25 | "summary": "Chilly" 26 | } 27 | ] 28 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/wwwroot/service-worker.js: -------------------------------------------------------------------------------- 1 | // In development, always fetch from the network and do not enable offline support. 2 | // This is because caching would make development more difficult (changes would not 3 | // be reflected on the first load after each change). 4 | self.addEventListener('fetch', () => { }); 5 | -------------------------------------------------------------------------------- /BlazorAppOdataClient/wwwroot/service-worker.published.js: -------------------------------------------------------------------------------- 1 | // Caution! Be sure you understand the caveats before publishing an application with 2 | // offline support. See https://aka.ms/blazor-offline-considerations 3 | 4 | self.importScripts('./service-worker-assets.js'); 5 | self.addEventListener('install', event => event.waitUntil(onInstall(event))); 6 | self.addEventListener('activate', event => event.waitUntil(onActivate(event))); 7 | self.addEventListener('fetch', event => event.respondWith(onFetch(event))); 8 | 9 | const cacheNamePrefix = 'offline-cache-'; 10 | const cacheName = `${cacheNamePrefix}${self.assetsManifest.version}`; 11 | const offlineAssetsInclude = [ /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/ ]; 12 | const offlineAssetsExclude = [ /^service-worker\.js$/ ]; 13 | 14 | // Replace with your base path if you are hosting on a subfolder. Ensure there is a trailing '/'. 15 | const base = "/"; 16 | const baseUrl = new URL(base, self.origin); 17 | const manifestUrlList = self.assetsManifest.assets.map(asset => new URL(asset.url, baseUrl).href); 18 | 19 | async function onInstall(event) { 20 | console.info('Service worker: Install'); 21 | 22 | // Fetch and cache all matching items from the assets manifest 23 | const assetsRequests = self.assetsManifest.assets 24 | .filter(asset => offlineAssetsInclude.some(pattern => pattern.test(asset.url))) 25 | .filter(asset => !offlineAssetsExclude.some(pattern => pattern.test(asset.url))) 26 | .map(asset => new Request(asset.url, { integrity: asset.hash, cache: 'no-cache' })); 27 | await caches.open(cacheName).then(cache => cache.addAll(assetsRequests)); 28 | } 29 | 30 | async function onActivate(event) { 31 | console.info('Service worker: Activate'); 32 | 33 | // Delete unused caches 34 | const cacheKeys = await caches.keys(); 35 | await Promise.all(cacheKeys 36 | .filter(key => key.startsWith(cacheNamePrefix) && key !== cacheName) 37 | .map(key => caches.delete(key))); 38 | } 39 | 40 | async function onFetch(event) { 41 | let cachedResponse = null; 42 | if (event.request.method === 'GET') { 43 | // For all navigation requests, try to serve index.html from cache, 44 | // unless that request is for an offline resource. 45 | // If you need some URLs to be server-rendered, edit the following check to exclude those URLs 46 | const shouldServeIndexHtml = event.request.mode === 'navigate' 47 | && !manifestUrlList.some(url => url === event.request.url); 48 | 49 | const request = shouldServeIndexHtml ? 'index.html' : event.request; 50 | const cache = await caches.open(cacheName); 51 | cachedResponse = await cache.match(request); 52 | } 53 | 54 | return cachedResponse || fetch(event.request); 55 | } 56 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | . 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /ConsoleConsumer/Brand.cs: -------------------------------------------------------------------------------- 1 |  2 | public class Brand 3 | { 4 | public int Id { get; set; } 5 | 6 | public string Name { get; set; } 7 | 8 | public string Description { get; set; } 9 | 10 | public decimal Tax { get; set; } 11 | 12 | public string CreatedBy { get; set; } 13 | 14 | public DateTime CreatedOn { get; set; } 15 | 16 | public string LastModifiedBy { get; set; } 17 | 18 | public DateTime? LastModifiedOn { get; set; } 19 | 20 | public virtual ICollection Products { get; set; } = new List(); 21 | } 22 | -------------------------------------------------------------------------------- /ConsoleConsumer/ConsoleConsumer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net7.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /ConsoleConsumer/Product.cs: -------------------------------------------------------------------------------- 1 |  2 | 3 | public class Product 4 | { 5 | public int Id { get; set; } 6 | 7 | public string Name { get; set; } 8 | 9 | public string Barcode { get; set; } 10 | 11 | public string ImageDataUrl { get; set; } 12 | 13 | public string Description { get; set; } 14 | 15 | public decimal Rate { get; set; } 16 | 17 | public int BrandId { get; set; } 18 | 19 | public string CreatedBy { get; set; } 20 | 21 | public DateTime CreatedOn { get; set; } 22 | 23 | public string LastModifiedBy { get; set; } 24 | 25 | public DateTime? LastModifiedOn { get; set; } 26 | 27 | public virtual Brand Brand { get; set; } 28 | } 29 | -------------------------------------------------------------------------------- /ConsoleConsumer/Program.cs: -------------------------------------------------------------------------------- 1 | using Simple.OData.Client; 2 | 3 | try 4 | { 5 | var client = new ODataClient("https://localhost:7003/odata/"); 6 | 7 | var products = await client 8 | .For() 9 | .Expand(x=>x.Brand) 10 | .FindEntriesAsync(); 11 | 12 | foreach (var product in products) 13 | { 14 | Console.WriteLine(product.Brand.Name); 15 | } 16 | 17 | } 18 | catch (Exception ex) 19 | { 20 | Console.WriteLine(ex.Message); 21 | } 22 | 23 | Console.ReadLine(); -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Spyros Ponaris 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ASP.NET Core OData Project 2 | 3 | A gentle introduction of ASP.NET Core OData project. 4 | 5 | ## Overview 6 | 7 | OData (Open Data Protocol) is a standardized protocol for building and consuming RESTful APIs. Here are some key benefits of using OData: 8 | 9 | Uniform Interface: 10 | OData provides a uniform and consistent way to expose and consume data over the web. It follows REST principles and uses standard HTTP methods (GET, POST, PUT, DELETE) to interact with resources. 11 | 12 | Queryable: 13 | OData supports a powerful query language that allows clients to request only the data they need. Clients can filter, sort, and project data on the server side, reducing the amount of data transferred over the network. 14 | 15 | Standardized Protocol: 16 | OData is an open standard that is maintained by the OASIS consortium. This standardization ensures interoperability between different systems and allows clients and servers from different vendors to communicate seamlessly. 17 | 18 | Metadata: 19 | OData services expose metadata that describes the structure of the data and the available operations. Clients can dynamically discover the capabilities of the service, making it easier to integrate with and use OData APIs. 20 | 21 | Rich Data Types: 22 | OData supports a variety of data types, including complex types and relationships between entities. This enables the modeling of rich data structures and complex relationships in a standardized way. 23 | 24 | Stateless Communication: 25 | OData follows the stateless communication principle of REST, meaning that each request from a client contains all the information needed by the server to fulfill that request. This simplifies the architecture and improves scalability. 26 | 27 | Batch Operations: 28 | OData supports batch requests, allowing clients to send multiple requests in a single HTTP request. This can improve efficiency and reduce the number of round-trips between the client and server. 29 | 30 | Cross-platform Compatibility: 31 | OData is platform-agnostic and can be used across various programming languages and platforms. Clients can be developed in different technologies as long as they adhere to the OData standard. 32 | 33 | Code Generation: 34 | OData clients can often generate client-side code based on the metadata exposed by the service. This simplifies the development process and reduces the chance of errors in client-server communication. 35 | 36 | Simplified CRUD Operations: 37 | OData provides a standardized way to perform Create, Read, Update, and Delete (CRUD) operations on data. This consistency makes it easier for developers to understand and implement these common operations. 38 | 39 | ## Prerequisites 40 | 41 | Specify any prerequisites that users need to have installed or set up before using your project. Include things like: 42 | 43 | - [.NET 7 SDK](https://dotnet.microsoft.com/download) 44 | - [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/) 45 | - Other dependencies... 46 | 47 | ## Getting Started 48 | 49 | Provide instructions on how to get started with your ASP.NET Core OData service. Include steps such as: 50 | 51 | 1. Clone the repository: `git clone # ASP.NET Core OData Project 52 | A gentle introduction of ASP.NET Core OData project. 53 | 54 | ## Overview 55 | OData (Open Data Protocol) is a standardized protocol for building and consuming RESTful APIs. Here are some key benefits of using OData: 56 | 57 | Uniform Interface: 58 | OData provides a uniform and consistent way to expose and consume data over the web. It follows REST principles and uses standard HTTP methods (GET, POST, PUT, DELETE) to interact with resources. 59 | 60 | Queryable: 61 | OData supports a powerful query language that allows clients to request only the data they need. Clients can filter, sort, and project data on the server side, reducing the amount of data transferred over the network. 62 | 63 | Standardized Protocol: 64 | OData is an open standard that is maintained by the OASIS consortium. This standardization ensures interoperability between different systems and allows clients and servers from different vendors to communicate seamlessly. 65 | 66 | Metadata: 67 | OData services expose metadata that describes the structure of the data and the available operations. Clients can dynamically discover the capabilities of the service, making it easier to integrate with and use OData APIs. 68 | 69 | Rich Data Types: 70 | OData supports a variety of data types, including complex types and relationships between entities. This enables the modeling of rich data structures and complex relationships in a standardized way. 71 | 72 | Stateless Communication: 73 | OData follows the stateless communication principle of REST, meaning that each request from a client contains all the information needed by the server to fulfill that request. This simplifies the architecture and improves scalability. 74 | 75 | Batch Operations: 76 | OData supports batch requests, allowing clients to send multiple requests in a single HTTP request. This can improve efficiency and reduce the number of round-trips between the client and server. 77 | 78 | Cross-platform Compatibility: 79 | OData is platform-agnostic and can be used across various programming languages and platforms. Clients can be developed in different technologies as long as they adhere to the OData standard. 80 | 81 | Code Generation: 82 | OData clients can often generate client-side code based on the metadata exposed by the service. This simplifies the development process and reduces the chance of errors in client-server communication. 83 | 84 | Simplified CRUD Operations: 85 | OData provides a standardized way to perform Create, Read, Update, and Delete (CRUD) operations on data. This consistency makes it easier for developers to understand and implement these common operations. 86 | 87 | ## Prerequisites 88 | 89 | Specify any prerequisites that users need to have installed or set up before using your project. Include things like: 90 | 91 | - [.NET 7 SDK](https://dotnet.microsoft.com/download) 92 | - [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/) 93 | - Other dependencies... 94 | 95 | ## Getting Started 96 | 97 | Provide instructions on how to get started with your ASP.NET Core OData service. Include steps such as: 98 | 99 | 1. Clone the repository: `git clone https://github.com/stevsharp/AspNetOdata.git` 100 | 2. Navigate to the project directory: `cd yourproject` 101 | 3. Build the solution: `dotnet build` 102 | 4. Run the ASP.NET Core OData service: `dotnet run --project AspNetOdata` 103 | 104 | ## OData Endpoints 105 | 106 | Includes examples of how users can interact with these endpoints, including filtering, sorting, and querying. 107 | 108 | ## Configuration 109 | 110 | ## Console Client and Blazor WebAssembly 111 | 112 | using Simple.OData.Client; 113 | 114 | try 115 | { 116 | var client = new ODataClient("https://localhost:7003/odata/"); 117 | 118 | var products = await client 119 | .For() 120 | .Expand(x=>x.Brand) 121 | .FindEntriesAsync(); 122 | 123 | foreach (var product in products) 124 | { 125 | Console.WriteLine(product.Brand.Name); 126 | } 127 | 128 | } 129 | catch (Exception ex) 130 | { 131 | Console.WriteLine(ex.Message); 132 | } 133 | 134 | Console.ReadLine(); 135 | 136 | ### Example: 137 | 138 | http 139 | https://localhost:7003/api/Product?$expand=Brand 140 | ` 141 | 2. Navigate to the project directory: `cd yourproject` 142 | 3. Build the solution: `dotnet build` 143 | 4. Run the ASP.NET Core OData service: `dotnet run --project YourODataServiceProject` 144 | 145 | ## OData Endpoints 146 | 147 | Includes examples of how users can interact with these endpoints, including filtering, sorting, and querying. 148 | 149 | ## Configuration 150 | 151 | ## Console Client 152 | 153 | using Simple.OData.Client; 154 | 155 | try 156 | { 157 | var client = new ODataClient("https://localhost:7003/odata/"); 158 | 159 | var products = await client 160 | .For() 161 | .Expand(x=>x.Brand) 162 | .FindEntriesAsync(); 163 | 164 | foreach (var product in products) 165 | { 166 | Console.WriteLine(product.Brand.Name); 167 | } 168 | 169 | } 170 | catch (Exception ex) 171 | { 172 | Console.WriteLine(ex.Message); 173 | } 174 | 175 | Console.ReadLine(); 176 | 177 | ### Example: 178 | 179 | http 180 | https://localhost:7003/api/Product?$expand=Brand 181 | 182 | ## Connect with Me 183 | 184 | [![LinkedIn](https://img.shields.io/badge/LinkedIn-Profile-blue)](https://www.linkedin.com/in/spyros-ponaris-913a6937/) 185 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 5.1.x | :white_check_mark: | 11 | | 5.0.x | :x: | 12 | | 4.0.x | :white_check_mark: | 13 | | < 4.0 | :x: | 14 | 15 | ## Reporting a Vulnerability 16 | 17 | Use this section to tell people how to report a vulnerability. 18 | 19 | Tell them where to go, how often they can expect to get an update on a 20 | reported vulnerability, what to expect if the vulnerability is accepted or 21 | declined, etc. 22 | --------------------------------------------------------------------------------