Can I set the data source for a combo box in an Entity Framework Core forms application at design time? - entity-framework

I feel so stupid.
I'm trying to create a simple Windows Forms application using Visual Studio 2022, .Net Core and Entity Framework. I am using the database-first approach. I have a simple database and a set of classes created from the the database by EF Core Power Tools's reverse engineering feature. I am trying to create a form that will manage vendors. I have a table named "vendors" with fields named "name" and "address". (That's enough for now.) EF Core Power Tools gave me a context class that I renamed to ForhpContext and a Vendors class.
On my form I have a combo box that I expect to contain the names of all of the vendors in my table, and a text box that will display the address of the selected vendor.
In the form design window, I can select the combo box and in its properties window, click the down arrow for the Data Source property. I get a little empty window with a link labeled "Add new Object Data Source..." When I click on that, I get a form labeled "Add and update object data sources". The form has an empty text box labeled "Filter" and a large box labeled Data Source Types. What do I do with this form? Can this form use any of the classes that were generated for me by Entity Framework? Is it possible to set up my EF data sources for the combo box and the text box at design time, or do I have to wait until run time and set them up in my Form Load event handler?
Is there a good book you can recommend that will teach me how to use EF in windows forms applications?

Related

Realtime datatable with asp.net core web app , EF core and SignalR

I want to retrieve data from Sqlserver database with EntityFramework core and do crud operations and show data table to client without refreshing the page (Realtime) , is there any source or example in this case ?
Not sure there is a definitive source for this, but it's not that hard to build yourself.
It should be relatively straight forward. In general you'd need
A model for the grid that defines the properties to show and edit, and also which row is selected.
An HTML Helper to change the rows from read-only to editable
A view to display the table.
An [edit] action link for each row enables you to select a row by ID for editing, and after clicking it, reloads the page and then the view can respond accordingly to change the type of the row from read-only to editable.
You could use Blazor or maybe Ajax to change a row from read-only to editable without refreshing the page, but I'm not sure if you need to meet certain requirements that discard using either of them.
John Ciliberti has written a recipe for a book, that works just like I described, find it on his Github page to get some ideas of what's involve.
If you need a more out-of-the-box solution, perhaps consider wiring up DataTables.js.

Similar to C# datacontext do we have anything in javafx?

I have a question and tried everywhere in world wide web. So this is my final destination.
I am developing an application (ETRM related) using javafx8 which is actually an application which is already developed using c# with wpf in my company. But the performance is not so good. so i'm trying to do it using javafx so that i can learn few things at the same time i will get some real application development experience.
Problem: (screen shots attached)
I open my application and i enter a trade number in a text field and say open. it should open the trade from db.
Here Trade is my domain entity which has many properties. for eg: a trade entity have a quantity, buyer and seller etc where buyer and seller are also domain entities.
So i open a new trade (first screen shot) and select the properties using the comboboxes and save the trade. this is the flow.
The first block what u see are all properties of the Trade entity**("Trader", "Type", "Contr. Status", Counterparty, etc).** It all loaded with default data. Now when i change any value, for ex. the "Trader" to "ABS" (2nd screen shot) it calls the "trader" property in the "Trade.cs" file (3rd screen shot) and sets the value. it is because the whole block or more precisely the whole tab what u see "Trade#: New1" is bound to the Trade entity at the window creation time itself, so that whenever u change any property on the screen it exactly call the respective getters and setters.
It is done by setting the datacontext of the tab to the trade entity in C#.
I want to achieve the same in javafx. I designed the UI exactly and populated all the data from DB to show in the comboboxes but dont know how to set the datacontext to the UI.
In C# i can bind my domain entity (trade) to a window and whenever i set values on the UI that gets set on the trade entity. datacontext may be the C# term but i want something similar in javafx.
Will it be possible to achieve in javafx?
Thanks in advance. Please let me know if u need further details.
enter image description here
enter image description here

Entity Framework: Added view appears in Model Browser but not Solution Explorer

I have a project which uses Entity Framework. I've added a view from my SQL Server database to the model using the Model Browser in Visual Studio 2012 such that it appears under the following items:
Entity Types under my model.
Entity Container, Entity Sets
.Store, Tables / Views
However, I can't access it from my code.
Back in Solution Explorer, under the Models folder, the view does not appear anywhere under the EDMX file for my model (though it DOES appear in the diagram).
I can not seem to find any practical way to add the view to my data model such that it is usable. Ultimately, I want to reference it via the entities object so I can select data from it.
Every Entity in EF should have unique identifier. Try to select a key column in view and then try to add view. View should be available to you

Add SQL Server extended properties to EF 4.0 model

Hi
Is there a way to make EF model automatically fetch SQL Server extended property into model? I've read about POCO, but I'm a little confused since it states that you should turn automatic code generation off. If you do that, does your model still update automatically when you add new objects? and how should I update my model so it gets the extended properties for each object(table or column) automatically and sets it in the model?
That's where T4 comes in. You turn off the automatic generation, and can choose a template you want for the objects(templates also generate the objects but according to your requirements). You can use already existing templates, or create your own. To add those templates, just double click on the .edmx, then right click on window, and Add Code Generation Item.

Programmatically creating menu hierarchy in Joomla

Let's say that I have a vast quantity of restaurant reviews in a database -- not Joomla articles, just database tables. I want to display these restaurant reviews as part of a Joomla 1.5 web site.
I can write a component to display each review. That part is fine. But rather than listing the reviews as a list on a page, I want to use the nice cascading menu that is part of the Joomla template that the site uses. But I don't want to have to add menu items one by one for each review; I want menu items to be generated automatically from the database contents. The menu of reviews should 'plug in' the existing menu structure for the web site (i.e., I want to supply the code that generates the menu items with an existing menu item so that it generates itself under that item).
How can I create code to programmatically create that menu? Component, plug-in, module, ...? Would the menu be generated at page display time, or "manually" in the admin panel (I'm ok either way). Any examples of this already?
I think the simplest way would be to create a custom menu module. The absolute basic one would just output the list of reviews in a <ul> and then use some css to style the list.
I ended up creating a component that creates the whole menu structure at once, upon admin request. It just creates rows in the jos_menu table, as if the menus were created manually. Updating the hierachy is a pain (and I haven't completed that part), but creating the structure from scratch is pretty simple and works well.