Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Trim trailing spaces from retrieved strings in EF Core

$
0
0

ASP.NET MVC Core 5 application uses Npgsql Entity Framework Core Data Provider to get data from Postgres database using Entity Framework Core. Columns in database are defined as CHAR(n) type, like

    create table prpalk (
    sfirmanimi char(100);
    )

Column types cannot changed to varchar.

Using EF commands like string nimi = ctx.Prpalks.Single().Sfirmanimi; to get data, strings in application contain also trailing spaces. How to remove trailing spaces automatically ?

Is there some event in EF Core which can used to trim all string columns when returned to application ?

I havent found such setting in EF data provider, Npgsql or Postgres database.

Column types cannot changed to varchar type due to compatibility with existing legacy application.


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>