I am using vb.net WinForms with SQL Server 2014. I have a form with various textboxes and checkboxes I am populating from the database with a BindingSource. The two tables with the relevant info are called Channel and Setup. A setup can have many channels while a channel belongs to one setup. In the setup table I have a field called CurrentSetup which indicates the active setup with a bit. I need to show info only from the channels that belong to the active setup. I tried putting "CurrentSetup='True'" on the BindingSource, but that doesn't seem to work because all my data is coming from the ChannelBindingSource which can only read the foreign key (Setup_id) from the Setup table, but can't access the rest of the table it seems.
So to sum it up, my question is how can I filter a BindingSource based on a field from a related table?
I'd add to that that I'm using the Entity Framework (6), and I've read that BindingSources aren't even the recommended way to do this, but it's the only thing I've found that seems to work so far. If I'm way off base with this, and should be doing something else I'm open to that too. I just still find BindingSources in the current (VS 2013) Microsoft documentation.
If you're using EF then you should be getting only the data you want using LINQ to Entities. It would be something like this:
Dim currentChannels = context.Channels.Where(Function(c) c.Setup.CurrentSetup)
That will then give you a list of all the Channel entities related to the Setup that has its CurrentSetup set to True.
Related
I am writing project on ASP.NET MVC 4. The database for this project was not originally designed, and the modification or addition of new tables in the database is done campaign work. I use ADO.NET EF DatabaseFirst. During the work I needed additional properties to store information that I have ordered in the class with the fields of the database.
After that, I need to add a new table, but all of my follow-up in class with fields disappeared after the model update ADO.NET. Who knows how to safely modify my model no change of work already done?? Thanks in advance.
I'm new to Drupal 7. Right now I'm trying to use D7 to build an interface that allows me to directly manipulate the tables in the database.
I have installed a couple modules such as Data, Migrate, Feeds, and etc. I managed to create a view to display the table that I created using Data Module, but I need to add and update the rows from the interface.
Furthermore, is it possible to set up relational tables so that I can update or delete related rows at the same time using Drupal?
Thanks in advance
Using the data module that is quite easy because it comes with the "Data Entity" submodule that creates an entity form for you. This allows you to update data table rows. It should add an edit button at the end of your data view for the table.
Using some basic custom code you can always create a form to add/update data to the table as well. For form creation please have a look at:
http://api.drupal.org/api/drupal/includes%21form.inc/group/form_api/7
Some days I love my dba's, and then there is today...
In a Grails app, we use the database-migration plugin (based on Liquibase) to handle migrations etc.
All works lovely.
I have been informed that there is a set of db administrative meta data that we must support on every table. This information has zero use to the app.
Now, I can easily update my models to accommodate this. But that answer is ugly.
The problem is now at each migration, Liquibase/database-migration plugin, complains about the schema and the model being out of sync.
Is there anyway to tell Liquibase (or GORM) that columns x,y,z are to be ignored?
What I am trying to avoid is changesets like this:
changeSet(author: "cwright (generated)", id: "1333733941347-5") {
dropColumn(columnName: "BUILD_MONTH", tableName: "ASSIGNMENT") }
Which tries to bring the schema back in line with the model. Being able to annotate those columns as not applying to the model would be a good thing.
Sadly, you're probably better off defining your own mapping block and taking control of the Data Mapper (what Hibernate essentially is) yourself at this point. If you need to take control of the way the database-integration plugin handles migrations, you might wanna look at the source or raise an issue on the JIRA. Naively, mapping your columns explicitly in the domain model should allow you to bypass unnecessary columns from the DB.
I'm using Siaqodb for my client side database engine in a Sync Framework silverlight project. I've switched to siaqodb because microsofts client side solution loads the entire database into memory at once and, as such, has a hard time handling large data.
I've bound a list of SiaqodbOfflineEntity objects to a silverlight datagrid in order to create an editable datagrid. Unlike microsofts solution, you can't bind the database entries directly to the datagrid. You have to query the database and bind a list of in memory objects to the datagrid. This causes a problem in that the database isn't immediatly updated when the datagrid cell is changed. I'm trying to find the best way to handle updates to the database after a change in the cell. I can't just update each item to the database because the siaqodb engine will mark the item as dirty even if no change was made to the object. This will cause conflicts when trying to sync. holding a cached version of the original list and then comparing each property of each object to find which ones have changed seems like it would work, but seems to be a bit cumbersome. I've also tried looking at some of the datagrids events but RowEditEnded doesn't appear to fire when a cell is edited and CurrentCellChanged seems to fire whenever I switch rows (odd).
There's got to be a better solution to this. Anyone have any ideas?
So I've gotten this to work by changing my offline entity classes to implement iNotifyPropertyChange and I think this is a reasonable solution. I set the PropertyChanged event to a function that saves the object to the database. There is a VS package called notifypropertyweaver that will inject this code at compile time, reducing the amount of work needed to be done on auto-generated entity code.
I am building a multiuser WPF application (requirement is a desktop app), database SQL Server 2008.
There are two types of users.
The first type user will enter a record which would be stored in a table.
The second type user initially will be presented with a listbox with the records from the table. The requirement is that the listbox must be updated live (i.e. if a new record is entered by the first user the listbox must be updated).
Currently I have not yet implemented the Database functionality.
I am currently working with ObservableCollection and simulating this scenario.
I would like to know the best approach for achieving this.
Should i use a timer and keep querying the table? Is there a more efficient way?
Is this even possible (should I switch to ASP.NET?) ?
I would appreciate any suggestions and tips that you may have.
Try using SqlDependency, since it can raise an event (OnChange) in your code when the results of a query would change on the server (as the result of an INSERT or UPDATE from another user or process, for example)
An example of its use on CodeProject for a simple live chat application:
http://www.codeproject.com/KB/database/chatter.aspx