I really need clear step by step instructions on how to do this.
I have looked back through the posts I have made in the last few weeks but I am coding in circles.
I wrote myself some long instructions in the comments at
https://www.devexpress.com/Support/Center/Question/Details/T317718
but they are failing me.
I noted that I need to use the report designer to set the bindingsource.datasource property to the business object that I want to report on.
I looked up a report that I had got working but the object is no longer visible in the report designer ( when I click the menu in the top left corner of the designer )
In the designer code I see that the correct binding is set however I should not have to edit generated code to get my new report.
[Update]
Here is the structure of my business object
C#public class SPResultString
{
public string Result { get; set; }
}
Here is my Reports dbContext
C# public class ReportsDB : jtDbContext
{
public IList<SPResultString> CancelOrders()
{
return GetSpResults("aaCancelTestOrders"); // returns 1 record
}
// etc
I have made the ReportDataV2_ListView accessible via a navigation item in my project and run the report from an action in a controller.
Here is my Action method
C#private void actRunReport_Execute(object sender, SimpleActionExecuteEventArgs e)
{
var report = (ReportDataV2)e.CurrentObject;
if (report == null)
{
return;
}
using (var db = new ReportsDB())
{
if (report.PredefinedReportType.Name.Contains("ClearTestOrders"))
{
var rep = new ClearTestOrders();
var xtraRep = (XtraReport)rep;
xtraRep.DataSource = db.CancelOrders();
xtraRep.ShowPreviewDialog();
}
}
// etc.
Here is me trying to figure out what options to put in.
I cant work out how to add SPResultString as the bound field
Hello Kirsten,
In the ticket you gave, we discussed at least two methods of accomplishing this task for Entity Framework Code First:
1. Bind an XtraReport's DataSource directly to the result of the Database.SqlQuery<T> query.
2. Use the SqlDataSource component as per How to use SqlDataSource with ReportsV2 and pass the application connection string into the data source?
Here you will need to design a regular XtraReport as per XtraReports documentation.
As far as XAF integration is concerned, in both cases you will need to handle the CustomSetupReportDataSource event as shown in the last link.
Please clarify the following:
With that, we will be in a better position to assist you further.
>>in both cases you will need to handle the CustomSetupReportDataSource event as shown in the last link
I dont want to pass the connection string. I want to set the datasource to a list of objects. I thought I managed this somehow before.
I see in a report that I did have working that the Designer.cs contains
this.bindingSource1.DataSource = typeof(Module.BusinessObjects.SPResultStripg); how would this have got into the report?
I have it working now , using the trick of editing the designer generated code.
But what steps are there to achieve this using the UI?
The UI now works the way I want, but how do I set it up to get there ? http://screencast.com/t/P4KMCwopPeW
Hello Kirsten,
Most likely your report shows no data because your newly created ReportsDB does not return any data from the CancelOrders method. Would you please verify this while debugging in Visual Studio?
In an XAF application it is best to instantiate an EFObjectSpace and then call your stored procedures through its ObjectContext property. You can find more information on this method in MSDN, e.g.:
https://social.msdn.microsoft.com/Forums/en-US/a7e15e64-5724-44ce-a047-d256424a1e7f/how-to-call-stored-procedure-from-entity-framework?forum=adodotnetentityframework
>>I have it working now , using the trick of editing the designer generated code.
>>The UI now works the way I want, but how do I set it up to get there ? http://screencast.com/t/P4KMCwopPeW
Please submit a separate ticket on the .NET | XtraReports product and attach your problematic sample project so we can research your exact situation and provide the best technical solution. Thanks in advance.
Thanks for your answer Dennis. Once I realized that my question was really about how to report on a collection of objects I was able to work out the answer. The fact that the data originally came out of a stored procedure got me side tracked. It is a bit of work to create the correct data object for the stored procedure results. The only shortcut I know is to use the Import Function feature inside the EF Model First (.EDMX ) approach.