Closed LucaGabi closed 5 years ago
Hello @LucaGabi ,
This library is EF Classic
based on EF6
and not EF Core
.
You look to want to use EF Core
. So unless I'm wrong, you probably want to post this issue here instead: https://github.com/aspnet/EntityFrameworkCore/issues
Best Regards,
Jonathan
Performance Libraries
context.BulkInsert(list, options => options.BatchSize = 1000);
Entity Framework Extensions • Entity Framework Classic • Bulk Operations • Dapper Plus
Runtime Evaluation
Eval.Execute("x + y", new {x = 1, y = 2}); // return 3
C# Eval Function • SQL Eval Function
Ok, thanks, still, is there a way to do it in the EF Classic ? Can I implement something to generate the correct query in EF ?
This can be closed if there is no useful info.
Some solution could apply but the easiest one would be to perhaps keep the mapping the same as your database and make the logic in the entity?
For example:
public class Book
{
public int ID { get; set; }
public string Fr_Title { get; set; }
public string Ru_Title { get; set; }
[NotMapped]
public string Title
{
get { return My.CurrentCulture == "fr" ? Fr_Title : Ru_Title; }
}
}
Fr_Title
and Ru_Title
could also be made internal/private if needed.
Could this solution work for you?
Thanks for the answer, it is a solution .. but this will load all the translations available for each query.
Yes,
Other solution will require more code if you want it to work with all possible scenario. For example, by using Interceptor to change the query.
If you want go this way, you can learn more about interceptor here: http://www.entityframeworktutorial.net/EntityFramework6/database-command-interception.aspx
Hello @LucaGabi ,
We will close this issue since it has been answered but let me know if you are looking for some more answer (we will re-open it).
Best Regards,
Jonathan
Hi,
I have the following case: my app has a known set of supported cultures, for each table/model, each varchar field, has a corresponding column for one of the known cultures, in the db - each column has a prefix for the culture e.g. book.title has a book.fr_title and book.ru_title. How can I use EF core to query the db in such way that it will get the data in to the model according to current culture ? In the model there is only one property book.title so the value should be mapped to this field. Is there a way to modify the EF Core generated SQL to select the correct column in the table according to the current culture - this is set in the db as a setting?
I would very much appreciate any kind of help. (I want it to work like this, no extra additions: var books.Where(b=>b.price>23.2).ToList();) I looked at computed properties but those did not work ..
Thanks.