MongoDB c# sharp Property vs Field vs Member vs Element - mongodb

Looking into Custom Serialization, what's the difference between
A "Property" BsonClassMap.MapProperty
A "Field" BsonClassMap.MapField
A "Member" BsonClassMap.MapMember

This answer should cover it:
What is the difference between a Field and a Property in C#?
C# fields are meant to be hidden. Properties expose fields.

From http://api.mongodb.org/csharp/1.0/html/18aadb76-2494-c732-9768-bc9f41597801.htm
MapProperty
Creates a member map for a property and adds it to the class map.
MapField
Creates a member map for a field and adds it to the class map.
MapMember
Creates a member map for a member and adds it to the class map.

Related

Binding a CollectionView item to a member variable, not a property

I am using .net MAUI's <CollectionView> with a nested <CollectionView.ItemTemplate> to bind to a collection of objects. I understand how to define the item template so that it contains Label objects that bind to properties of the objects in the collection: using (for example) Text="{Binding Surname}". This works correctly.
I'd also like to bind to a collection of objects that expose readonly member variables, not properties, but binding by name does not result in a value being displayed. No runtime errors occur.
Is there a way to bind collection view items to member variables?
(Using VS 2022 Preview 7.4.0 with .net 6)
Is there a way to bind collection view items to member variables?
No, it only works with public properties. This is simply the way it's implemented. The XAML binding engine will go through the object that serves as a binding context and will look for public properties only.
A work-around is to add a property that returns the member variable.
Given MyType MyVariable;, add:
public MyType MyProperty => MyVariable;
That is shorthand for public MyType MyProperty { get { return MyVariable; } }.

How code generate from protege data property with getter single value instead collection?

I have a simple model in protege of class and data property.
But when I use code generator - in generated class - property getter have type - Collection< String > instead simple String.
I try to add something like with different types predicate in class:
"title some xsd:string"
But it is Collection yet.
Is it can be done in protege and how? May be example ontology?

replacing drools getter lookup for non-pojo

Drools supports the usage of properties of Pojos using a simple name. For example Person(age==10) to match a Person instance that has a getAge() method returning 10.
My problem now is that I have to handle something that is not a pure Pojo and instead has a generic getter. So for the Person example above I need a transformation to Person(myGenericPropertyLookupMethod("age")==10). And I need this for all such property usages, which includes for example the usage of from and chaining like $street : String() from $person.address.street. where at least street must be looked up using myGenericPropertyLookupMethod.

Class Diagram: How to represent an array of something as an operation parameter?

In an interface method I want to have a collection of SomeType as an input parameter. How do I represent that within a Class Diagram in EA?
I tried using "SomeType[]" as parameter type, but EA doesn't seem to keep track of this: for instance when I rename the class SomeType to something else, the change doesn't propagate here.
You can specify multiplicity for each parameter of your method.
Parameter multiplicity is not directly visible in the class diagram even if you select "Full detail" in Parameter visibility in Diagram properties. But it is in the model.
The answer is unfortunately: you can't. EA does store the name only and not the reference to the class when you specify a parameter. There are other places where that's also the case (I currently can't recall where). So if you need to track that you need to write a smart SQL to list the used parameters.
Such a SQL could look like:
SELECT * FROM t_operationparams where Type = '<Search Term>'

Type of A field is its Class Name. What is this called in C#?

I new to C#, Sometime I see C# code like this
public class ClassName
{
ClassName field;
}
It mean the field type the same as Class name. WHat this mean and called in C# ?
It is a reference to an instance of the type itself. E.g. An element in a linked list could reference the next element or if the type was a WebPage, it could have a reference to another WebPage.