Open per-samuelsson opened 6 years ago
Tested changing above use case with synonym and changed synonym to a property (variant below) in a populated database, restarted and made some queries. Everything work as expected.
Recommended practices. The general:
Before
[Database] public class Foo {
public string Bar;
[SynonymousTo("Bar")]
public string Fubar;
}
After
[Database] public class Foo {
public string Bar { get; set; } // <-- Strongly adviced: change to property instead of field
public string Fubar {
get { return Bar; }
set { Bar = value; }
}
Before
[Database] public class Foo {
public Foo Bar;
[SynonymousTo("Bar")]
public Narrowed Fubar;
}
[Database] public class Narrowed : Foo {}
After
[Database] public class Foo {
public Foo Bar { get; set; } // <-- Strongly adviced: change to property instead of field
public Narrowed Fubar {
get { return (Narrowed) Bar; }
set { Bar = value; }
}
[Database] public class Narrowed : Foo {}
Before
[Database] public class Foo {
public string Bar;
[SynonymousTo("Bar")]
public readonly string Fubar;
}
After
[Database] public class Foo {
public string Bar { get; set; } // <-- Strongly adviced: change to property instead of field
public string Fubar {
get { return Bar; }
}
The very basics
With synonym
When bound, we have metadata such as:
Doing this query produce expected result ("Bull") and below queryplan:
Queryplan:
Without synonym
When bound, we have metadata such as:
And query:
Queryplan