Hello,
I have problem with InsertOrUpdate method. I have created custom repository (I follow documentation). In that custom repository I have added one method where I get Entity by some parameters. The problem is now when I execute that method and then InsertOrUpdate method (from Base Repository) it gives me error:
Attaching an entity of type 'EntityName' failed because another entity of the same type already has the same primary key value.
Here is code:
public async Task Save(DetailsInput Input)
{
//check
var country = _countryRepository.GetByPeriod(Input.DateFrom, Input.DateTo.Value);
if (country != null && ((Input.Id.HasValue && taxRate.Id != Input.Id.Value) || !Input.Id.HasValue))
{
throw new UserFriendlyException(L("CountryForPeriodExists"));
}
Country item = Input.MapTo<Country>();
await _countryRepository.InsertOrUpdateAsync(item);
}
But if I remove that custom method and then try to execute InsertOrUpdate everthing is ok:
public async Task Save(DetailsInput Input)
{
Country item = Input.MapTo<Country>();
await _countryRepository.InsertOrUpdateAsync(item);
}
Is anyone know why this happens?
Thanks.
Hi,
I figured out what was the problem. The problem was in encoding of log4net.config file. I changed encoding to UTF-8 without BOM and I now can se logs.txt file under *.WebHost project's bin folder.
Regards.
Hello,
I'm using Angular 2 + .NET core tempate and I have the same configuration as @codemonkey21. My project references are: abp.castle.log4net (1.5.1) castle.loggingfacility.mslogging (1.1.0)
Startup.cs
public IServiceProvider ConfigureServices(IServiceCollection services)
{
//MVC
services.AddMvc(options =>
{
options.Filters.Add(new CorsAuthorizationFilterFactory(DefaultCorsPolicyName));
});
//Configure CORS for angular2 UI
services.AddCors(options =>
{
options.AddPolicy(DefaultCorsPolicyName, p =>
{
//todo: Get from confiuration
p.WithOrigins("http://localhost:4200").AllowAnyHeader().AllowAnyMethod();
});
});
//Swagger - Enable this line and the related lines in Configure method to enable swagger UI
services.AddSwaggerGen();
//Configure Abp and Dependency Injection
return services.AddAbp<SuperhikWebHostModule>(options =>
{
//Configure Log4Net logging
options.IocManager.IocContainer.AddFacility<LoggingFacility>(
f => f.UseAbpLog4Net().WithConfig("log4net.config")
);
});
}
log4net.config
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender" >
<file value="App_Data/Logs/Logs.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10000KB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5level %date [%-5.5thread] %-40.40logger - %message%newline" />
</layout>
</appender>
<root>
<appender-ref ref="RollingFileAppender" />
<level value="DEBUG" />
</root>
</log4net>
I can't find log file on location that @codemonkey21 find his or in any other part of my project. I tried to change location of file in log4net.config but nothing helps. What could be the problem? Is there any way to debug log4net?
Any help would be appreciated
Hi,
thanks for your reply. This is exactly what I did :)
Hi,
I was still in initial phase of project and I download template again and since then it is working ok.
Thanks for reply.
Hello,
I'm using . NET Boilerplate + Module Zero starter template. I have a question regarding to AuditLogs. I want to get list of all items from table AbpAuditLogs from Application layer. Can you help me and explain how can I implement this?
Many thanks.
Hello,
I have problem with loading localization values on Angular 2.X template. At first it works ok, but after some time I realized that I'm getting empty object as a response of method AbpUserConfiguration/GetAll:
I didn't change anything that is related to localization logic:
Can you tell me where in .NET core project is starting point of that request (for getting all configurations)? What can be the possible reason for that problem? Any help would be appreciated. Thanks.