XtraReport and xrTable shows only 1 record - reporting

I have a linq to sql generated object MyObject and this contains an EntitySet.
Now i use an XtraReport with a BindingSource.DataSource = MyObject. I have a xrTable in the Detail band (which is the only one i use btw) with four xrTableCells binded binded to properties from MyObject.MyotherObject.Property. It keeps showing me only the first record and not all of them.
Anyone with an idea?

I believe you'll need to implement the ITypedList with your custom object to use it as a datasource. Check out this online documentation article for more info:
http://www.devexpress.com/Help/?document=XtraReports/CustomDocument4046.htm

I have just solved a similar problem. Did you use typed datasets to help you layout the report at design time? If you did then clear the Data Source in design view. If you apply LINQ to SQL Data Source at runtime without clearing the typed dataset Data Source in the design view, you may get only one row showing in the detail band.

i have similar problem and tried above answers, but it was so simple
just set your report DataMember to the name of your sub collection MyObject.MyotherObject
and the table will load all items in your sub collection.
XtraReport report = new XtraReport(){DataSource = MyObject,DataMember="MyotherObject" };

Related

LINQ update statement using generic table and column names

OK, I've seen a lot of posts on creating generic LINQ statements, but these are usually based on select queries. What I need is a LINQ UPDATE statement that takes a generic parameter for the table to update and a generic parameter for the column to update.
The data model I'm working with has dozens of tables, and each table has potentially dozens of columns. What I'm really driving toward is a single Update statement that allows me to tell it at runtime which table and which column to update.
Dealing with data typing of these dynamically supplied fields will also be an issue since obviously I can't update a DateTime column with a decimal value for example.
So, can anyone point me at some code that shows a LINQ update process using generic parameters for table and column names.
Any help would be greatly appreciated!
You didn't specify Entity Framework with DbContext but if that is what you are using, this is pretty easy. The following code is written to work within the NerdDinner sample which can be downloaded from http://nerddinner.codeplex.com/
This code locates a dinner based on the id and sets the address property to "New Value"
Dinner dinner = db.Set<Dinner>().Find(id);
var entry = db.Entry(dinner);
entry.Property("Address").CurrentValue = "New Value";
db.SaveChanges();

I used the Data Source Configuration Wizard to create a connection to an Access database

I used the Data Source Configuration Wizard to create a connection to an Access database and fill a listbox. All is well except the list is not sorted. If I set the sort order via the properties dialog, then the list is sorted, but the associated textboxes that display information from the database are still sorting in the order that was defined in the dataset.
I know I need to sort the dataset, but since the Wizard created the connection, I don't know how to find the code. The only code I can find is in the form load section and it is as follows:
this.membership_LogTableAdapter.Fill(this.membership_Log_DataSet.Membership_Log);
I tried to manipulate the sort order by doing the following, but it did not work:
this.membership_Log_DataSet.DefaultViewManager.DataViewSettings["Membership_Log"].Sort = "Last_Name ASC";
Anyone have any ideas?
It looks like you're filling/binding-to individual datatable. If is the case, try setting sorting of that specific table:
this.membership_Log_DataSet.Membership_Log.DefaultView.Sort = "Last_Name ASC";
I figured it out. I double clicked the Membership_Log_DataSet.xsd file in the solution explorer and then I right clicked the Fill,GetData method and clicked properties and then I was able to alter the SQL command text by adding ORDER BY Last_Name to the auto-generated SQL code.

Core data, bindings, NSArrayController and table views - how to generate a view of a core data context

I have a working system that lets me build a database containing instances of various entities , all linked together nicely.
Before I knew I would care, I came across a tutorial on using Core Data and bindings, and it went through a complete case where you get a table showing all the entities of some type with a column for each property. It showed both the UI side and the Data model side - not that I need the data model part at this point. Now, darned if I can find it. This is one of those things that is supposed to be easy, and requires virtually no code, but getting exactly the right connections in UIBuilder is not going to happen if I can't find instructions.
Also, I thought I came across an example of something like a query editor where the user could select which properties to sort on, which to match on, etc. Did I imagine that?
Anyone out there know where I can find such?
Sure, you can do this without code:
Add an array controller to your nib.
Bind or connect an outlet for its managed object context
Set the array controller to Entity mode, fill in the entity name, and select Prepares Content.
Bind your table view columns to array controller's arranged objects, and fill in the key name for the model key.
Regarding the query editor, open up the model, and on the Editor menu click Add Fetch Request.
I found at least a partial answer to the query editor question, in this apple tutorial. Not sure how far it will get me, as I prefer to write code where possible, since then I can leave a trail of comments.

How to update tables from a View using Linq to Entities

I have a View in an SQL Server Database, which involves many different tables. I am using Linq to Entities to access the database, so I have no problem getting and showing view's result.
But the problem is when I want to modify some field in those results. As long as a view doesn't have a primary key, the Entity is read-only, so the question is:
Is there any way to modify the object with the view's data and save those changes in the corresponding tables?
Sorry for my english, but it's not my native language.
Thank you very much in advance!
There are some requirements for VIEW to be updatable. Take a look here. You say your view references many tables, so you have to implement INSTEAD OF trigger.

How do I edit a Telerik RadGrid when using multiple tables as a data source

I have asked this question on Telerik forums with no reply so I'm turing to you.
I have seen this topic come up before but without an answer so I thought I'd define the problem as simply as possible.
I have a LINQ command creating a query:
var gridData = from au in dc.aspnet_Users
join aur in dc.aspnet_UsersInRoles
on au.UserId equals aur.UserId
join ar in dc.aspnet_Roles
on aur.RoleId equals ar.RoleId
join am in dc.aspnet_Memberships
on au.UserId equals am.UserId
select new
{
au.UserName,
ar.RoleName,
am.Email,
am.IsApproved,
am.IsLockedOut
};
THE IMPORTANT POINT IS THAT THIS USES MORE THAN 1 TABLE.
Note: This is accessing the Roles and Users tables using the standard ASP.NET Membership framework.
Then I have a simple RadGrid:
<MasterTableView EditMode="InPlace">
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
</MasterTableView>
Finally I bind the data to the grid in Page_Load
rgUsers.AutoGenerateColumns = true;
rgUsers.DataSource = gridData.ToList();
rgUsers.DataBind();
rgUsers.EditIndexes.Add(1);
rgUsers.DataBind();
GridView1.AutoGenerateColumns = true;
GridView1.DataSource = gridData.ToList();
GridView1.DataBind();
GridView1.EditIndex=1;
GridView1.DataBind();
This will display the data from the 4 tables correctly.
I included a GridView to compare functionality.
I also put the grid into Edit mode programatically to make sure that this was not just a problem with the Edit button.
However, when in Edit mode the RadGrid fields are not editable.
I have tried the following:
1) 1) I can use a LinqDataSource that allows Edit/Update BUT only if there is only 1 table in the LINQ query.
2) 2) I can use a ObjectDataSource onto a dataset but once again this only works if the the dataset adaptor is accessing a single table.
I have looked at the variouse suggested demos and example code but they have all ignored the multiple table/Join problem:
www.telerik.com/community/code-library/aspnet-ajax/grid/automatic-operations-with-linqdatasource.aspx
demos.telerik.com/aspnet-ajax/grid/examples/dataediting/threelevel/defaultcs.aspx
www.telerik.com/community/code-library/aspnet-ajax/grid/automatic-operations-with-linqdatasource.aspx
I am not wedded to LINQ. I am quite happy to adapt in order to get a RadGrid that can support Update and Edit to multiple tables.
What should I do to achieve a RadGrid that displays records composed from multiple tables with Update and Edit available?
Thanks for any help
Richard
Have you considered using ADO.net's dataview class in conjunction with a dataset class? You should be able to pull you data using the system.data.sqlclient class with a stored proc if that is the type of database you're using. You can preserve your database's relationships in the dataset class and the dataview class will allow you to view the data as if it were a single table. Then you should be able to bind the dataview class to the Telerik control.
Why not using NeedDataSource binding as opposed to DataBind() calls? Thus the Telerik grid should manage its editing states without extra coding. If you use joins for different source tables and set you update or insert commands using appropriate T-SQL statements, everything should work fine. Check out this demo for a start:
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/extractvalues/defaultcs.aspx
Dick
Turns out that the LINQ query returns an anonymous type that is read only.
I replaced it with a SQLDataSource using stored procedures so it works now.
Thanks

Resources