Automapper: filling object properties from Httpcontext post parameters - automapper

I'm trying to set up a quick generic way of populating a poco object through posted values in an httpcontext.params. I'm thinking about using automapper but before launching in the code i'd like to have a quick idea:
is this possible? do you have samples, or hints?
is this overkill? isn't there in the huge .net stack something that already fills this need?

Yes for sure, It's how asp.net mvc handles the input parameters of a request and build an object.
It takes a lot of time and energy for you to implement this.

Related

nestjs get method/function caller name or stack

I have a service that has a method (A.method()) which is called by other methods from multiple services (B.method(), C.method()...).
I want to know somehow what's the method caller name or the service that called my method.
The only working solution I found until know is throwing a dummy error and checking error.stack, but this is dirty :)
PS: I'm not using any controller/resolver, just functions that are starting because of cronjobs or constructors.
I tried interceptors & auth guards but it seems they do not work for simple methods.
I think the error stack is enough information.
If you find the name is ugly, then you should add sourceMap for better function name and file location.
Another approach ( maybe a bit overkill ) is to add tracing like Jaeger or OpenTelemetry to visualize the functions call, execution time and many other information.

How to overwrite generic ODATA expand handling functionality

We are currently working on performance issues with our provided OData interface, since the UI5 issues a read request with multiple expand paths attached. Due to the generic handling of the request by the framework this leads to an additional processing per expand option, which we need to prevent.
Reading the blog about this topic there seems to be a way to overwrite the generic handling somehow:
https://blogs.sap.com/2018/03/19/sap-cloud-platform-sdk-for-service-development-create-odata-service-7-more-navigation-read-create-expand-sqo/
In this case it is us who need to decide if we can afford to rely on the FWK-functionality. Of course, such generic support cannot be performant. But for small amount of data it is just nice to get it for free.
Stay tuned to learn how to overwrite such generic FWK-functionality with own specific implementation.
However, there is no further blog post on this and looking through the framework, my only idea to overwrite this would be to configure and use an own com.sap.gateway.core.api.provider.data.IDataProvider implementation which handles the request in a custom way, although this would be an immense workaround.
So the questions is if there is some leaner or easier approach to overwriting this functionality which I missed?
UPDATE:
I was update to create a custom data provider and register it with the RuntimeDelegate after servlet initialization. This custom data provider would then check for a custom annotation on the mapped method handler to see if expand should be handled or not. If not it will just read the entity, but not perform he generic expanded read. This works more or less fine, but what is of course missing is a way to pass the properties to be expanded in the ReadRequest. So far only a static implementation is possible solving our performance problem, but I would gladly have a hint if there is another, better solution for this...
At the time of this writing, no better approach exists at the moment.

yii objects and object fields

I'm not sure how to put this right.
I need to use yii to create an application which needs to use objects and fields.
Let's say that in my app I want to have those three objects: Computers, Servers, IPs. Each of these three objects will have it's own attributes:
Computer: CPU, Motherboard, Video adapter, IP (related to the object IP), Aquisition Date
Servers: Name, IP (related to object IP), etc...
IP: IP Address.
As you can see I also need a way to link my objects between them.
Every kind of attribute (object field) must be treated in it's own way, after it's own type. For example, we have a field called CPU which can be in a list of values. We have Aquisition Date and it must be treated like a date.
Well, the problem is that I need an extension to help me in creating those object types and setting their attributes. I don't know how to search for something appropriate.
Implementing this functionalities will take me a lot of time which I don't have right now. If there are no extensions, do you have any solution to implement one? I have some ideas for creating classes for every user field, classes which will implement an interface that render the methods properly for insert, update, etc.
Thank you!
You don't need any extension if you use Yii. You'd rather yake some time to read the tutorials. My advice is to begin with Larry Ullman's Learning Yii Series and then to go to the Definitive Guide
Once you have set your database and build your tables, you will only have to activate the Gii component of Yii framework and to use it's automated code generators to build your basic models, views and controllers.
The only thing you've left will be customization, of course. Yii + Gii save you all the repetitive work. But... read the docs.
[EDIT] after the OP comment below.
Is it an EAV model that you are looking for ? There is an unofficial Yii extension dealing with that : EAV Behavior. I have no idea whether it's good or not, as I definitely avoid to work with EAV databases. Let us know your opinion if you try to use it.

bind textbox with core framework

i already searched for an answer but without finding one to my specific problem.
i am using core data to save profiles and display them in a table. since core data is already set up, i wanted to use it also for storing application settings.
i've set up the model, set up an array controller to retrive the data, but now, i have no clue on how to connect this array controller to a single textbox.
i try to explain: theoretically my model could have more entries, just like the profile model has. but it has just one with some settings, as if a database would have only a single data row. is there a way i can specify that i want the data contained in the very first row? dont know if my question is clear, its not so easy to explain. please if it was not clear let me knwo and i will try to explain it again.
thanks
igor
Don't put application settings in Core Data. Any time you find yourself thinking that you want just one instance (row) for an entity, you're doing it wrong.
Cocoa Touch provides a class called NSUserDefaults specifically for the purpose of saving app settings. Look into that, it's almost certainly what you want.

How to get more ways of interrogating my data source from subsonic

In the below link, Linq-To-Sql produces a range of methods to get data back based on various real-world needs (e.g. recent topics, etc).
How can I get Subsonic to produce me a set of classes which would interrogate and return data back from my data source in such a way? I get classes which really just present CRUD ops.
Thanks
I don't see a link here but in general I'd say you can use SubSonic 3 in much the same way you can Linq to Sql. Here's some sample code:
http://subsonicproject.com/docs/Linq_Select_Queries
Other than that I'd need more specific examples.
The way I would do it with SubSonic is to make a view with the way you want the data to be formatted, and then retrieve it with SubSonic.

Resources