Hi, I have a problem retrieving data.
<ins>Entity definition</ins>
public class AtmData : FullAuditedEntity<long>
{
[Required]
public virtual DateTime TransDate { get; set; }
/// <summary>
/// Montant de la transaction
/// </summary>
public virtual decimal TransAmount { get; set; }
}
<ins>DbContext :</ins>
public virtual DbSet<AtmData> AtmTrans { get; set; }
<ins>Application Service</ins>
private readonly IRepository<AtmData, long> _atmTransRepository;
var atmTrans = _atmTransRepository.GetAll() ;
But GetAll() always returns nothing. I have the same problem with all tables defines with PK other then the default type int. All tables defined with default Pk int work fine.
Please help, I'm unable to see the problem for 2 days now.
Regards Abdourahmani
6 Answer(s)
-
0
Just to add than I'm using the latest Asp.net core (v4.5.1) with angular
-
0
Hi @abdourahmani,
Did you see /ProjectName.Host/App_Data/Logs.txt? Is there any error message?
-
0
Hi @abdourahmani,
Can you share your app service method's full code ? AspNet Zero already contains entities with different PK than integer and there is no problem with that. Maybe you have another problem.
Thanks.
-
0
<cite>ismcagdas: </cite> Hi @abdourahmani,
Can you share your app service method's full code ? AspNet Zero already contains entities with different PK than integer and there is no problem with that. Maybe you have another problem.
Thanks.
Hi ! Here it is :
using System.Linq; using Abp.Domain.Repositories; using Abp.EntityFrameworkCore.Repositories; using Lbi.RapproDab.AppBusiness; using Lbi.RapproDab.AppEntities; using Microsoft.EntityFrameworkCore; namespace Lbi.RapproDab.AppService.Rappro { public class RapproAppService : RapproDabAppServiceBase, IRapproAppService { private readonly IRepository<Agence> _branchRepository; private readonly IRepository<AtmTerminal> _atmRepository; private readonly IReconciliationManager _rapproManager; private readonly IRepository<AtmTransaction, long> _atmTransRepository; private readonly IRepository<Acquereur, long> _acqRepository; private readonly IRepository<Emetteur, long> _emtRepository; private readonly IRepository<CaisseAtm, long> _caiTransRepository; private readonly IRepository<ReconciledTrans, long> _recTransRepository; public RapproAppService(IReconciliationManager rapproManager, IRepository<AtmTerminal> atmRepository, IRepository<Agence> branchRepository, IRepository<AtmTransaction, long> atmTransRepository, IRepository<CaisseAtm, long> caiseRepository, IRepository<ReconciledTrans, long> recTransRepository, IRepository<Emetteur, long> emtRepository, IRepository<Acquereur, long> acqRepository) { _rapproManager = rapproManager; _atmTransRepository = atmTransRepository; _caiTransRepository = caiseRepository; _atmRepository = atmRepository; _branchRepository = branchRepository; _recTransRepository = recTransRepository; _emtRepository = emtRepository; _acqRepository = acqRepository; } public void ReconcileAll(bool initDb = true) { var branches = _branchRepository .GetAll() .Include(p => p.AtmTerminals); foreach (var agc in branches) { ReconcileBranch(agc.BranchCode, initDb); initDb = false; } } public void ReconcileBranch(string branchCode, bool initDb = true) { var atms = _atmRepository.GetAll() .Include(p => p.BranchId) .Where(a => a.BranchId.BranchCode == branchCode) .ToList(); foreach (var atm in atms) { ReconcileAtm(branchCode, atm.AtmCode, initDb); initDb = false; } } public void ReconcileAtm(string branchCode, string terminalId, bool initDb = true) { var atmTrans = _atmTransRepository.GetAll() .Where(a => a.TerminalId.Equals(terminalId)); var caiTrans = _caiTransRepository.GetAll() .Where(a => a.CaTermId.Equals(terminalId)).ToList(); var recData = _rapproManager.CustomerTrans(atmTrans, caiTrans); var emtTrans = _emtRepository.GetAll().Where(a => a.CaTermId == terminalId); recData = _rapproManager.EmetteurTrans(recData, emtTrans); var acqTrans = _acqRepository.GetAll().Where(a => a.CaTermId == terminalId); recData = _rapproManager.AcquereurTrans(recData, acqTrans); recData = _rapproManager.CancelledTrans(recData); var db = _recTransRepository.GetDbContext(); if (initDb) { const string sql = "Delete from ReconciledTrans;"; db.Database.ExecuteSqlCommand(sql); } db.AddRange(recData); db.SaveChanges(); } } }
Regards.
-
0
<cite>alirizaadiyahsi: </cite> Hi @abdourahmani,
Did you see /ProjectName.Host/App_Data/Logs.txt? Is there any error message?
Here is the only message I found witch can be seen as an error message.
WARN 2017-10-09 14:54:48,920 [4 ] Mvc.ExceptionHandling.AbpExceptionFilter - Login failed! Abp.UI.UserFriendlyException: Login failed! at Lbi.RapproDab.Web.Controllers.TokenAuthController.<GetLoginResultAsync>d__32.MoveNext() in D:\MyWorkingDir\Lbi.RapproDab v4.5.1\aspnet-core\src\Lbi.RapproDab.Web.Core\Controllers\TokenAuthController.cs:line 511 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Lbi.RapproDab.Web.Controllers.TokenAuthController.
-
0
Hi @abdourahmani,
Your code seems fine. You can check Sql Server profiler to see if queries are executed on DB or not. I assume there are some extra where caluses which prevents getting data from database.