Fluent ....HasTableName(..) works only first time (version 1.0.7.4)
See original GitHub issueSeems like changing mapping TableName with fluent mapping works only once per process instance.
Example: I have a set of tables with same data models.
// Data model class (for different tables):
public class SomeModel
{
[Column("id")]
public int Id { get; set; }
[Column("field")]
public string Field { get; set; }
}
// Testing mapping same class with different tables (in different instances of DbConnection!)
public void Test()
{
var confName = "Test";
// map to table1
using (var db = new LinqToDB.Data.DataConnection(confName))
{
db.MappingSchema.GetFluentMappingBuilder().Entity<ModelBase>().HasTableName("table1");
var q = db.GetTable<ModelBase>(); // = sql=... from "table1"...
var t = q.ToArray(); // <--- mapped to "table1"
}
// map to table2
using (var db = new LinqToDB.Data.DataConnection(confName))
{
db.MappingSchema.GetFluentMappingBuilder().Entity<ModelBase>().HasTableName("table2");
var q = db.GetTable<ModelBase>(); // = sql=... from "table1"... !!
var t = q.ToArray(); // <--- still mapped to "table1", not "table2" !!!
}
}
I am using linq2db version 1.0.7.4 Maybe I’ve missed something?
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
linq2db 5.0.0-preview.1
LINQ to DB is a data access technology that provides a run-time infrastructure for managing relational data as objects.
Read more >Fluent API - Configuring and Mapping Properties and Types
In this article. Model-Wide Settings; Property Mapping; Type Mapping; Model Used in Samples. When working with Entity Framework Code First the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Why you do not use db.GetTable< ModelBase >().TableName(‘table1’).Select… ?
Awesome. Thanks in advance!