Questions tagged [anonymous-objects]
56 questions
1
vote
1 answer
LINQ to Entity - using anonymous object in a query
I am trying to write LINQ2Entity query which will return only 3 columns from the table and then to set the result as a DataSource of a ComboBox.
The problem I have is this. First - to select all from the table I use a service like…

Leron
- 9,546
- 35
- 156
- 257
0
votes
1 answer
Anonymous object as generic type
I have the following generic interface:
public interface IDatabaseEntity
{
public T GetKey();
}
Now, I define several entities which all implement this interface. An example:
public class Player : IDatabaseEntity
{
public Guid…

Silas
- 40
- 7
0
votes
1 answer
Why do I can't access to non-private member of anonymous object in Kotlin?
I am a java developer and now I am learning Kotlin.
I've met an interesting(working) piece of code:
class C {
private fun getObject() = object {
val x: String = "x"
}
fun printX() {
println(getObject().x)
}
}
But if…

gstackoverflow
- 36,709
- 117
- 359
- 710
0
votes
0 answers
Anonymous Object in Java / JVM
Where will Anonymous objects are stored in JVM memory. How to get hashcode of the Object?
public class Outer {
public class Inner {
public void display() {
System.out.println("Inner class method");
}
…
0
votes
1 answer
How to pass an anonymous object to a generic method with multiple generic types?
Let's say I have this generic method:
public T1 GenericTest(T2 Obj, out T2 NewObj)
{
NewObj = Obj;
return default;
}
How do I pass an anonymous object to it?
What do I put in place of the "???" when calling the method in the…

user3163495
- 2,425
- 2
- 26
- 43
0
votes
0 answers
Store class with property and value into Config file
I have an api endpoint that returns these settings to a client HTML/JS that retrieve these data through either normal XML request or promise or async/await.
return new JsonResult(
new List

Noelia
- 39
- 7
0
votes
0 answers
How do I get to a field of an anonymous type?
I'm trying to work out how to get to the anonymous return value from my WebApi Controller, it does something like this:
public IActionResult Get() {
using var db = DbDataContextFactory.Make();
return Ok(new {
feedTypes =…

push 22
- 1,172
- 3
- 15
- 34
0
votes
1 answer
Passing anonymous object of derived class to a routine in Eiffel
Assuming that we have:
class A ...
class B inherit A ...
f (a_a: A) ...
Then, can you write something like the following pseudocode, without using a temporary variable?
-- `y` is an argument to B's constructor.
f (create B.make(y))

Eleno
- 2,864
- 3
- 33
- 39
0
votes
3 answers
C# return (dynamic or anonymous?) object with return values from other methods as properties
I would like to return an object, which stores the return values from other class methods as properties on the return object. The problem is that I do not know which is the best way to do this in C#. Currently I am using a sort of JavaScript-ish…

user2768479
- 716
- 1
- 10
- 25
0
votes
1 answer
'object' does not contain a definition for in asp.net core 3.1
there are two parts to this question
number 1:
im having receiving the same issue as in this post
the only diff is that im running in asp.net core v3.1
Dynamic Anonymous type in Razor causes RuntimeBinderException
ive tried the expando solution
but…

toy
- 422
- 1
- 7
- 19
0
votes
2 answers
Different Kinds of passing objects to Arrays
Is there a difference between creating an object and then passing it to ArrayList Or directly creating an object in ArrayList.add method?
In case of memory use and performance?
Example:
ArrayList arrayList = new ArrayList();
//Type 1:
ClassX…

Bytheway
- 21
- 4
0
votes
1 answer
How to get Anonym Objects parameters?
Im trying to add my anonymous objects from a class to a Hashtable. I created my Hashtable as my teacher wants but there is one problem. I have to get x and y values one of my Objects. But System cannot find x anyway.
public class…

Hürkan Doğan
- 31
- 5
0
votes
4 answers
C# generic utility to check JSON string for anonymous type
I have a JSON string. I want to check if it contains an anonymous object. If it does then return the value. If it doesn't then return a default value. I then want to be able to repeat this multiple times for different anonymous objects.
Here is a…

Stephen Richardson
- 47
- 5
0
votes
2 answers
Why anonymous object passed as pointer is denied for some compilers?
Trying to run this code, to see how anonymous object ctor/dctor are called in a single expression:
#include
#include
using namespace std;
class Test {
public:
int mA = 0;
Test() {
mA = 1000;
…

markzzz
- 47,390
- 120
- 299
- 507
0
votes
1 answer
No default constructor exists for class c++
Hello,
I'm trying to instantiate an anonymous object with a std::string variable 'name'. But intellisenen gives me error saying
E0291 no default constructor exists for class "Player" GoldGame e:\C++ Projects\Hello…

Michael Song
- 51
- 2
- 6