[Solved] If C# attribute work like decorator design pattern?

You cannot compare these two things. Attributes are used to be accessed via reflection. They don’t change behaviour magically. You might probably (ab)use attributes to implement some kind of weird decorator design pattern. But just because an Attribute “decorates” e.g. a member, class, method or something, it has nothing to do with the decorator design … Read more

[Solved] How to delete a Product

Maybe you should first read the documentation of using CosmosDB: here On this page you can see how you can query your product and then delete this record from your collection: var query = client.CreateDocumentQuery<YourDocumentModel>(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), “<your sql>”, queryOptions); with this result you can update the object (yourDocumentModelObject) and remove the product from the subcategory. … Read more

[Solved] New class object error : Object reference not set to an instance of an object [duplicate]

This is your problem: _cache.TryGetValue(“CountsStats”, out countStats) out will change the object that countStats is pointing to. If it’s found in the cache, then it will be the cached object. Great! If it isn’t, then it will be null. You need to create a new instance in this case. You should change your code to … Read more

[Solved] Can’t use Count() in C#

Your resource is not a list but an object. Better implementation would be something like this. [HttpGet(“{id}”)] public IActionResult Get(string id) { using (var unitOfWork = new UnitOfWork(_db)) { var r = unitOfWork.Resources.Get(id); if (r == null) { return NotFound(); } return Ok(ConvertResourceModel(r)); } } 0 solved Can’t use Count() in C#

[Solved] occurred using the connection to database ‘ESCRestaurantDB’ on server ‘.\SQLEXPRESS’ [closed]

Now I haven’t computer with development enviroment with me to test, but I thing you forgot put return statment in opt lambda funtion: CreateMap<Item, ItemToReturnDto>() .ForMember(dest => dest.ItemImages, opt => {return opt.MapFrom(src => src.ItemImages); } If you could paste some more code of how you is call map funtion, we could help you. 4 solved … Read more

[Solved] Streaming large file across multiple layers

Found the solution by using HttpClient instead of RestSharp library for downloading the content directly to browser The code snippet is as below HttpClient client = new HttpClient(); var fileName = Path.GetFileName(filePath); var fileDowloadURL = $”API URL”; var stream = await client.GetStreamAsync(fileDowloadURL).ConfigureAwait(false); // note that at this point stream only contains the header the body … Read more

[Solved] ASP NET Core (MVC) problem with passing parameters from the view to the controller

Because the parameter names you accept are answer1, answer2, you should have a matching name in your view to make it possible to bind successfully. You can modify your front-end code as follows(DropDownListForto DropDownList): @model CommonEntity @using (Html.BeginForm(“Find”, “Hello”)) { @Html.DropDownList(“answer1”, new SelectList(ViewBag.Location, “Title”, “Title”)) @Html.DropDownList(“answer2”, new SelectList(ViewBag.JobTitle, “Title”, “Title”)) <button type=”submit”>Find</button> } Your Controller: … Read more

[Solved] Generic class of one type to another type in auto mapper

For Mapper.Map<PagedList<CasteModel>>(result);, you need to initialize Mapper like below in Startup.cs public void ConfigureServices(IServiceCollection services) { Mapper.Initialize(cfg => { cfg.AddProfile<AppProfile>(); }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); } But, it it recommended to use Dependence Injection to resolve Mapper. Install Package AutoMapper.Extensions.Microsoft.DependencyInjection Startup.cs public void ConfigureServices(IServiceCollection services) { services.AddAutoMapper(typeof(Startup)); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); } UseCase public class ValuesController : ControllerBase { private readonly … Read more

[Solved] .NET CORE Time asynced method

When an asynchronous method starts getting complicated it’s a sure sign something is wrong. Most of the time async code looks almost the same as synchronous code with the addition of await. A simple polling loop could be as simple as : public async Task<string> waitForCampaignLoadAsync(string uri) { var client=new HttpClient(); for(int i=0;i<30;i++) { token.ThrowIfCancellationRequested(); … Read more

[Solved] Minimal Hosting Model: Exited from Program.Main with exit code = ‘0’

The error messages aren’t terribly intuitive, but this error essentially means that the application ran, and then immediately exited. A common cause of this is when you neglect to add the Run() command at the end of the Program: app.Run(); Background This is easy to miss if you’re focused on migrating your ConfigureServices() and Configure() … Read more