Questions tagged [backing-field]

36 questions
2
votes
4 answers

Is there a performance difference between properties vs. backing fields in read/write operations?

When working within a class on its own fields and properties, I typically only use the property when it performs some function (like limiting a value or validating or whatever). Otherwise I prefer to read/write the backing field directly. I somehow…
user164226
2
votes
2 answers

How to access the backing field of a base class using fluent nhibernate?

How do i set the Access Strategy in the mapping class to point to the base _photos field? public class Content { private IList _photos; public Content() { _photos = new List(); } public virtual IEnumerable Photos …
Akk
1
vote
3 answers

Can I define a custom getter for a C# auto-implemented property (a.k.a. auto backing field)?

Note: I know how to accomplish this without using auto-implemented properties, but I'm wondering if C# has a built-in way to do this. Let's say I have this simple example of an auto-implemented property (a.k.a. auto backing field): public class…
1
vote
2 answers

Android : Translate in Java the Kotlin ViewModel backing field encapsulation technique

In an Android App written in Kotlin, LiveData properties in the ViewMoel can be encapsulated using the backing field technique like so : private val _score = MutableLiveData() val score: LiveData get() = _score How can I translate…
u2gilles
  • 6,888
  • 7
  • 51
  • 75
1
vote
1 answer

EF Core 3.1: Navigation property doesn't lazy load entities when calling the backing field first

I am using EF Core 3.1.7. The DbContext has the UseLazyLoadingProxies set. Fluent API mappings are being used to map entities to the database. I have an entity with a navigation property that uses a backing field. Loads and saves to the database…
1
vote
1 answer

Why do we need the backing fields in EF Core?

Why do we need the backing fields in EF Core? Why would someone want to use a field instead of a property while working with the entities? I can not come up with such a case. That probably means that I do not understand or I am missing something…
qqqqqqq
  • 1,831
  • 1
  • 18
  • 48
1
vote
1 answer

How to use get() with backing fields in kotlin

in the below code I am trying to create a getter method as a backing field. so that, when the getLastNameLen property is invoked it should return the length of the lastNameset. please refer to the code below and help me to fix the bug. how to…
Amrmsmb
  • 1
  • 27
  • 104
  • 226
1
vote
1 answer

How to display values from the backing fields

i would liek to run the simple example mentioned below. eclipse generates an error says: main class cant be found or loaded please let me know how to fix this error and why it happens in the below code I am trying to use the backing fields.…
Amrmsmb
  • 1
  • 27
  • 104
  • 226
0
votes
1 answer

how do you name (and map) a backing property?

In a few cases, I have a property that needs a "backing property" for practical reasons. For example, I have one type with a Name property - there is no transformation of the value happening on access, it merely triggers an action of some kind; a…
mindplay.dk
  • 7,085
  • 3
  • 44
  • 54
0
votes
0 answers

What is actual advantage of backing property in Kotlin?

I recently started working on Kotlin getters and setters and thereby landed on topic of Backing Properties in Kotlin. I am aware of the concept of Backing Field in Kotlin. I was refereeing to a book called Kotlin in depth by Aleksei Sedunov, in…
stardep
  • 129
  • 1
  • 13
0
votes
1 answer

.NET EF Core - The specified field could not be found for property

I'm trying make a migration in .NET EF Core but still getting error: The specified field '_tags' could not be found for property Document.Tags I need to save string array (tags) as one string separated by comma to the database. I…
JD_1609
  • 39
  • 5
0
votes
1 answer

nhibernate collection query with private backing field

I have a mant-to-many relationship modeled in the database (with a bridge table) between Student and Professor (_students_selected) , in my entites i have modeled it as a one-to-many relationship i.e. a Professor has one Student. …
super ted
  • 21
  • 2
0
votes
1 answer

When is a Dart private get function without backing field used?

I am going thru this example https://docs.flutter.dev/cookbook/persistence/reading-writing-files The following class is defined with private get functions but there are no backing fields. What do they mean and when are they useful? Esp. _localPath…
Polymath
  • 630
  • 7
  • 11
0
votes
1 answer

Why am I seeing a "No coercion operator is defined" exception when attempting to update a record with a backing field?

I might not fully understand how the backing fields work inside of EF Core, but I'm surprised to see this exception appear when I attempt to save records - and I haven't been able to find any information about it. I am using C# 9 records with change…
0
votes
0 answers

How to store data with backingfield in EF Core?

I have the following class public class InvestorsLottery : Lottery { [Column(TypeName = "decimal(14, 2)")] public decimal Investment { get; set; } [Required] public int Percentage { get; set; } [Required] [Column(TypeName =…
Noah Bergh
  • 493
  • 4
  • 14