hanks for your answer! That's what I had done and I know it works. In order to create the connection I'm reading the connectionstring like this:
var connectionString = ((JObject)(JObject.Parse(File.ReadAllText("appsettings.json")))["ConnectionStrings"]).Property("Default").Value.ToString();
Is there a better way that doesn't involve having to constantly read the appsettings file?
I tried with ConfigurationManager
but I can't get it to work
Thank you!
Good Morning
ASPNETZERO 8.4 / ANGULAR 8.3 / DOT NET CORE 3.1 / EF CORE 3.1 / POSTGRESQL DATBASE
I am making a manager to use create reports using SQL queries written by me, instead of leaving them to the FE for efficiency reasons. I already have dapper working properly for repositories, but I can't run an anonymous resoults query because dapper is asking me for a class to return the results to. I would use something like this in my reportsManager in the CORE layer, but I don't have a sql library in that layer, that is in the framework layer.
public class ReportsManager: VCloudDomainServiceBase,IReportsManager
{
private readonly IDapperRepository _genericDapperRepository;
public ReportsManager(IDapperRepository<GenericGroupDescription3Dto> genericDapperRepository)
{
_genericDapperRepository = genericDapperRepository;
}
public Task<IEnumerable> GetSalesByGroupRtdmAsync()
{
DateTime dateI = new DateTime(2020, 05, 01).ToUniversalTime();
DateTime dateF = new DateTime(2020, 05, 30).ToUniversalTime();
int restaurantId = 13;
var sqlQuery = @"SELECT article_name Description, sum(quantity) Value1, sum(quantity * unit_price) Value2, sum(0) Value3
FROM rtdm_orderitem OI JOIN rtdm_order O ON OI.order_id = O.id
WHERE O.restaurant_id = {0} AND O.created_timestamp between {1} AND {2}
GROUP BY article_name
ORDER BY 2 desc
LIMIT 10";
var connectionString = ((JObject)(JObject.Parse(File.ReadAllText("appsettings.json")))["ConnectionStrings"]).Property("Default").Value.ToString();
using (var connection = new NpgsqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
{
return connection.Query(sqlQuery, new {restaurantId, dateI,dateF});
}
}
}
So I create this generic class where to receive the results of the querys, but it doesn't work because I can't create it because I have to create the DbSet.
public class GenericGroupDescription3Dto : Entity
{
public int Id { get; set; }
public string Description { get; set; }
public decimal Value1 { get; set; }
public decimal Value2 { get; set; }
public decimal Value3 { get; set; }
}
<br> Is there a way to create a class that can be used by dapper to receive the results of a sql query? Is the approximation right or is the whole approach wrong?
Thanks!!
<br> <br>
After many tests, regenerating the project, for some reason that I cannot determine, is already working correctly.
Very strange since there were no changes in sources files or configuration, just recompile several times.
Just for the record: I recreate the project with the same name and now its apears to download with core 3.0. regards!
Hi @maliming!
I have the same simtomps and the same problem, as i report at https://support.aspnetzero.com/QA/Questions/8018.
Just ignoring the exception does not work because I cannot access the login page. An "InternalServerError" always appears on the angular page. This only happens to me with a project recreated from v7.2 to v8.0 with core 3. If I generate a demo project with v8 that works smoothly.
Update: Generate the project with the same name again and download it. This time it came configured with .net core 3 correctly, but still giving the same error from the angular application.
Hello! First of all I wanted to congratulate you on the product, I have been using ABP a year ago and it seemed so good that it is worth moving to the commercial version, AspNetZero. I acquired a license 25 days ago and created a project and downloaded it. At that time the project was in Asp.Net Core & Angular v7.2.3 and .Net Core 2.2. I saw that the new version, v8.0, came out with support for .Net Core 3.0. But when I want to download the project I only see that I can download version v8.0 but for .Net Core 2.2. I download it and see that indeed all projects point to .Net Core 2.2.
If I upgrade all projects to .Net Core 3.0, compile Ok and manual swagger tests work. But if there is the angular app it gives an error in the browser "InternalServerError". Log information is as follows:
Microsoft.IdentityModel.Tokens.SecurityTokenInvalidSignatureException: IDX10503: Signature validation failed. Keys tried: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.] '. Exceptions caught: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.] '. token: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.] '. at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature (String token, TokenValidationParameters validationParameters) at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken (String token, TokenValidationParameters validationParameters, SecurityToken & validatedToken) at VCloud.Web.Authentication.JwtBearer.VCloudJwtSecurityTokenHandler.ValidateToken (String securityToken, TokenValidationParameters validationParameters, SecurityToken & validatedToken) in D: \ Source \ Unidata \ ASPNetZero \ ASPNetZ-core \ ASPNetZero \ ASPNetZ-core \ ASPNetZ-core3 VCloud.Web.Core \ Authentication \ JwtBearer \ VCloudJwtSecurityTokenHandler.cs: line 40 at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync () INFO 2019-11-14 16: 46: 01,353 [24] uthentication.JwtBearer.JwtBearerHandler - Bearer was not authenticated. Failure message: IDX10503: Signature validation failed. Keys tried: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.] '. Exceptions caught: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.] '. token: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.] '. INFO 2019-11-14 16: 46: 01,354 [24] Microsoft.AspNetCore.Hosting.Diagnostics - Request finished in 3956.4738ms 404 DEBUG 2019-11-14 16: 46: 06,786 [19] HttpRequestEntityChangeSetReasonProvider - Unable to get URL from HttpRequest, fallback to null DEBUG 2019-11-14 16: 46: 12,285 [4] HttpRequestEntityChangeSetReasonProvider - Unable to get URL from HttpRequest, fallback to null DEBUG 2019-11-14 16: 46: 17,775 [4] HttpRequestEntityChangeSetReasonProvider - Unable to get URL from HttpRequest, fallback to null DEBUG 2019-11-14 16: 46: 23,258 [4] HttpRequestEntityChangeSetReasonProvider - Unable to get URL from HttpRequest, fallback to null
Questions: 1-When downloading the project already created, it should not come already configured in .Net Core 3.? 2-Any idea why I have the error indicated?
One last point. I downloaded a demo project (v8.0.0, Aspnet core 3.0 + Angular) in a new database (the demo project IS configured for .net core 3.0 by default) and that project works perfectly for me.
I have been with this problem for several days and I can't find how to solve it This is my 3 post on the subject regards!!
What is the correct way to perform an update from 7.2.3 to 8? I bought the product only 20 days ago and there are already two versions.
From the download page I see that I can download the project in version v8.0.0 but with .Net Core 2.2.
I have no problem starting with a project from scratch because there is little customizations already does in these 20 days.