I am building a hierarchy structure from scratch and I am trying to determine the best route to take. I found the following link below from another StackOverflow question:
Nested Set Model
I like the idea of nested sets and have begun to build my database, based on this pattern. I am now unsure how to query the data out in such a way that I will easily be able to bind to a control, such as the TreeView. I will need to be able to reorder and commit the data back as well. Any suggestions?
SQL 2005 added support for recursive queries. I'm using a recursive query to return a tree of data that populates a TreeView. For each record, I find the matching parent node from the TreeView and add its new child.
For updates you could serialize the tree to XML, then use the XML features in sql 2005 to run an "update" statement.
Related
I'm encountering a very odd problem. Since 2 days I cannot add new tables from my db in the model.
They appear in the list of addable tables, no error are shown at the validation but then, they don't appear in the Entity lists, and they still appear in the "addable" part of the menu.
The problem appears in
We've tried from different computeurs, so it's not a problem of my specific visual studio.
We've tried with other dbs, and the problem doesn't affect them. It affects boths of my prod and developpment dbs though.
We've tried with the exact same credentials to log to the db (not window authentication as we usually do), and the problem remains, so it's not a problem of rights.
We're a bit out of ideas right now :/
Does someone have an idea what it could be?
Thanks
Ok, we've found where it came from.
The table we wanted to add had no PK, and then when we tested we created mock tables without PK.
Once we add a PK the import goes well =)
If you're using a Code First approach then Entity Framework will build the table for you. It looks like you are not using Code First, so you will have create the table in the database. I assume you're using an Entity Data Model (.edmx)? If so, you will create your table in the database, then update your data model (.edmx). If you have not yet created your .edmx file, you need to do that - the .edmx file will contain all your CRUD operations.
What I'm confused about is I'd imagine your code would throw an error if the table did not exist (i.e. if the table represented by your data model didn't map to an actual table in the database, because it doesn't exist). So, the question is, does your table already exist? If it does, then step through the code line by line to find out why your records aren't being saved. If it doesn't exist, then add the table via SQL Server Management Studio (or similar), then open your .edmx file, right click on the layout that comes up, click "Update Model from database".
I am using vs 2012, .net 4.5, entity framework 5, web forms, vb (but c# help just as good for me)
I am new to using the Entity framework. I have decided to create a new project in .net 4.5 so i can use item Type for strongly typed data controls, in this case gridview.
I need to retrieve data from multiple tables 5+, which by its self is easy enough, but this means i cant use EntityDataSource as theres no option to build a query etc only select a single table. How can i achieve this plesae? I guess in the code behind i can set the gridview datasource but then do i need to implement custom paging and sorting?
I presume in this case i wont be able to use a strongly typed data control but i can live with that, does that mean its only viable for getting data from 1 table. Or do i need to populate my model with all results. The amount of data in the tables is well over 500,000 rows so obviously it has to be paged! And the page has a number of filters / search otpions
I am at a loss here, mainly i obviously am not understanding something.
I have been researching / googling this for a few hours som findings are below, but again they dont really answer or help me.
http://weblogs.asp.net/dwahlin/archive/2013/03/26/asp-net-4-5-web-forms-features-strongly-typed-data-controls.aspx
http://forums.asp.net/t/1677303.aspx/1
One option is creating a view with whatever you want in your database and then regenerating your EDMX to include the view. You will then have a strongly typed object designating the fields in the View.
I've read tons of sites on this. There are many "Examples" if you call some code with no explanation of how it was generated (design view vs typed) an example or just want to use simple select and update statements.
I have a Gridview. I am populating it using code from a stored proc. Now I want to edit the data. I have nothing set in the properties of the Gridview through design view (datasource, columns, etc.) My question is, how can I set this to allow editing and use a SP to send it back to the database?
Do I have to now manually create columns with code since I chose to not set properties in the design view?
Is it better to set the properties in design view and go that route? I started that way, but had problems when it came to updating with a SP.
I guess the whole do it in the designer vs do it in code thing has me confused.
I started adding RowEdit, RowCommand, etc. to the html and c#, but still don't see the EDIT/CANCEL on the webpage when I run it.
Learn to use the ObjectDataSource. It gives you maximum freedom of what way of storing the data you use - you delegate the select, update and delete to an external class where you just write your code which uses ado, linq, hibernate, a webservice or just anything.
Coding your views directly against fixed database structure would hurt you sooner or later.
Is it possible to have nested collections within Alfresco? I'm on Community Edition 3.4. I'd like to have a collection that contains other collections.
Is there something I need to do while defining the collection in the content model XML?
tl;dr: it's not supported out of the box
The data list model defines dl:dataListItem as a child type of cm:content, therefore you can't nest data lists the same way you nest documents into folders.
What you could do is to create a custom peer association between data lists, in order to create your own nesting logic. This would require refactoring the Share UI components that handle list to let them get knowledge of such a custom model, and show nested lists appropriately.
What you could do is define your own custom constraint.
Instead of using the predefined LIST constraint, you could refer to a Java class.
Here is a link to the Wiki
So you could define a nested collection. But to present this in either Explorer or Share, you'd have to write new renderers/generators(explorer) or new share template for that specific field.
I have a database I'd like to create an entity from, and then generate RESTful output.
My objective is to add a property to one of the tables once it becomes an entity. The data for that property would be one I'd come up with through calculations done on a few different fields in the table. From there, the code generator would create RESTful output like it normally does.
I have managed to be able to update the SSDL, CSDL, and the mapping sections of the edmx file along with using the SampleEdmxCodeGenerator as a custom tool. When I have all the sections in the edmx file filled out with my custom property, the svc fails because (I'm assuming) the property doesn't exist in the database. If I leave the property out of the SSDL, but put it in the client schema (CSDL) and the mapping section, I can't build my project.
I've modified the partial class and added to it, but the problem there is that I need to populate the methods on the creation time of the class, and I haven't been able to do that yet.
Am I headed in the right direction, or is this not possible? It seems like I should be able to do this with minimal effort, but I keep hitting walls.
I think you're taking detours to get where you want. I haven't used either of these approaches (recently), so they might not do exactly what you're after, but you could try this:
Create a partial class file right next to the .edmx model, which has the same name as your entity.
In it, specify the property you want as a read-only property, that does the calculations on each get.
Partial Classes and Partial methods were the first part of my answer. What I'm essentially trying to do I can't do. I can manipulate data that is returned by using partial methods and partial classes. I can plug the OnmethodnameChanged() method to format the data how I'd like it to be shown, but that only gets me part way to my desired result.
What I would also like to do, is create a property c, which doesn't exist as a column in the database (and therefore does not exist in my entity), calculated from a couple different properties in the database (say a and b), and then add property c to the entity framework class. In doing this, I figured it would then get generated into the RESTful webservice output.
A problem that occurs comes from the need for the class to update any changes you make, and have it propagate back to the data source. I didn't care about that, because I want my property to be read only. From what I've gathered this isn't possible.
For reference, these two posts really helped:
Adding custom property to Entity Framework class
(I can only post one url currently, so here is the address to the other article)
social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/b7a9e01d-c5c2-4478-8f01-00f7f6e0f75f
What I've decided to do, is to expose my entity as I've done so far, then consume the RESTful service that manipulates data and reformats it, and introduces needed properties. I'll turn the results into my own data object, and use that as a datasource to be exposed by yet another RESTful web service. I think this website gives a good example on how to expose a custom datasource.
mstecharchitect.blogspot.com/2008/12/surfacing-custom-data-source-in-adonet.html
If for some reason that is too slow, I suppose I could just make another table in my database that has a reworking of the data, and the calculated output in a format I'm looking for. The thing I want to avoid is having my resulting client having to do any of the data manipulation since it will be on some micro devices like palms, iphones, and blackberries.
Hope that helps anyone else with the same problem. It seems that is a shortfall in the current version of Data Services, but to some extent, I'm sure they'll be addressing it in later versions. Maybe T4 and .net 4.0 will be addressing it. I'm not sure.