Replies: 4 comments 7 replies
-
Context removed from expressions to avoid it's get stuck in insternal expression caches. What do you do with expressions so it makes difference for you? |
Beta Was this translation helpful? Give feedback.
-
Thank you for the response. I don't directly interact with the expressions. I just noticed it's the only field that is different from the previous version we were building. I am debugging and I am trying to look for clues of what the issue could be and that was one of them. Is there a reason why the POCO would be throwing a "Missing Table or View" error? Could I have missed updating all necessary files after the update, or is there a configuration that I am overlooking in my setup? |
Beta Was this translation helpful? Give feedback.
-
We currently do not have mappings set up. Our project follows the following setup approach. I will share snippets to our files for reference, which cover the entire setup. These are the changes that I only made after bumping up the version
Nothing has been changed apart from that. Below are our service setups that might give an overview of what is going on: In var connectionString = "";
var linq2DBStartUp = new Linq2DBStartUp();
linq2DBStartUp.Init(connectionString);
services.AddSingleton<IDBCommandService, DBCommandService>();
services.AddSingleton<IDBConnectionService, DBConnectionService>(); In public class Linq2DBStartUp : ILinq2DBStartUp
{
private bool _started;
public void Init(string connectionString)
{
if (!_started)
{
DataConnection.DefaultSettings = new Linq2DbSettings(connectionString);
_started = true;
}
}
} In public class DBCommandService : DataConnection, IDBCommandService
{
public DBCommandService(string connectionString, int slidingExpirationInSeconds = 1) : base("Oracle")
{
DefaultSettings = new Linq2DbSettings(connectionString);
LinqToDB.Common.Configuration.Linq.CacheSlidingExpiration = TimeSpan.FromSeconds(slidingExpirationInSeconds);
}
} In public class DBConnectionService : DataConnection, IDBConnectionService
{
public DBConnectionService() : base("Oracle")
{
AddInterceptor(new ConnectionInterceptor()); // Introduced this as part of the version updates
}
public ITable<User> User => this.GetTable<User>(); // previously this was only GetTable<User>().
} |
Beta Was this translation helpful? Give feedback.
-
User Class: namespace Database.User
{
[Table(Name = "users")]
public sealed class User
{
[PrimaryKey]
[Column("id")]
public long ID { get; set; }
[Column("name")]
public long? Name { get; set; }
}
} SQL Generated on running the following: var updatedUser = await db.User.Where(x => x.Id == "id")
.Set(i => i.Name, "NewName")
.UpdateAsync(); SQL: -- Oracle Oracle.Managed Oracle12
SELECT
u."id"
FROM
"users" u |
Beta Was this translation helpful? Give feedback.
-
We recently upgraded our LINQ to DB version from 3.4.x to 5.4.0, which was a significant leap. Unfortunately, this transition required a few adjustments before everything worked smoothly again. While raw queries are functioning as expected, we're encountering issues when attempting to use POCO classes for querying or updating data.
Here's a snippet of our
DataConnection
setup:And here's an example of a POCO class:
We're encountering issues when attempting to perform an update operation like this:
The error message we receive is "ORA-00942: table or view does not exist". Upon further investigation, we found that the
Expression
property ofdb.User
shows{null.GetTable()}
instead of{(DBConnectionService).GetTable()}
, which was observed in the previous version.This discrepancy suggests that the LINQ to DB context might not be properly initialized or accessed within our application. If anyone knows the cause of this, I will appreciate the feedback and help
Beta Was this translation helpful? Give feedback.
All reactions