crystal report datasource to business layer object colletion - asp.net

In my project I want to use data source for a crystal report as collection of business layer object.
How do I do this? I have 3 projects together in my solution one of them is business object layer.
In grid and comboboxes or other controls I am able to bind these objects to the collection directly.
I know how to bind crystal report to the object collection when class is in the same project but not to the class which is in different project of current solution.
Thank you

May be its too late for you, but I'll post an answer, in the case that it helps others.
I had the same problem - where you cannot see the classes from other projects in .NET objects section of Crystal Report, but still you can add them.
Steps to add class as data source from other project:
Go to Database Expert
Click on Create new connection
Make new Connection form ADO.NET (XML)
In popup window add a full class name in the editable drop down
Click finish
Thats it ...

Related

binding devexpress xtrareport EFdatasource at runtime

I'm trying to bind a xtraReport-EFdatasource to a list, i have done this in designer mode quickly using the wizard, but i cant bind its datasource at runtime.
DataSource = Services.CoursesList();
I tryed this code in the report constructor, also in the XtraReport1_DataSourceDemanded event with no luck. the devexpress website show an example using bindingsource, but im using EFdatasource. Can you help me with a code sample please?
I suggest you refer this - How to use Entity Framework with Xtrareports
The best way to accomplish your task is to place your Report class and
Entity objects into a separate class library. In this case, you will
be able to bind the Report to a custom object at design time and
provide data at run time.
To pass data to your Report instance, handle the
XtraReport.DataSourceDemanded event, create your Entity objects,
and pass them to the XtraReport.DataSource property.
More References:
How to use the XtraReport with the Entity Framework

MVC3 with EF Dbfirst, how to generate "controller with read write actions and views"

I am learning MVC3 and EF with DB first approach.
In some videos of MVC3 with code first approach from Scafolding Options they choosed "controller with read write actions and views" and after selecting Model and Data Context classes some code was automatically generated.
In my working I have a separate class library which has EF model in it (please see blue selected area in diagrame) . Please guide me how to access that EF and its generated classes to use with controller with read write actions and views ?
EDIT
I am adding new Controller.
I am not getting the comments you mentioned in your picture.
I am getting some classes in Model Classes drop down but not my EF classes are there in list.
I have not done any refrencing to class library in my MVC project. Please guie me how and what where to do ?
Thanks
I believe you're referring to MVC Scaffolding
Install-Package MvcScaffolding
If it shows No Model Classes availble, when you hover it will give you a more verbose description:
If you get this message, cleaning and rebuilding should fix your problem.
Is your database project referenced by your main project? In your main project click references, add new reference - then in the projects tab select the name of the project with your edmx:
After that, clean and build!

Accessing Classes in Asp.net

In web application, i am created one new project in that i added class library, like business layer, datalayer, but when i am accessing the business class in datalayer, class object is created but, when i am accessing the fileds of that class like example :
EmpBL objEmb= new EmpBL();
objEmb is not coming in intellesence, even i am not accessing the fileds of business class can you help me out please.
right click on your data layer project, select Add Reference and select Project tab - then add reference to your .Business project.
However, you can now have circular references, i.e. you can't reference each other. And normally, Business Objects project references Data Access project, not the other way around. Although any architecture is possible, and sometimes BOL project is just storage classes, and they don't know anything about DAL - a third project brings them together. Not sure about your exact architecture.

Visual Studio 2010 Report Viewer

I have been trying to use report viewer for a couple of days now and got no where. I have an ASP.Net WEB APLICATION, not a WEB SITE. Which every tutorial relates to.
I used the report viewer last week in another project and it worked perfectly.
What im trying to achive is to create a new report using business objects. NOT a SQL connection. Previously when i used the report viewer when adding new DataSet to the Report Data window all of my namespaces in my objects library (a seperate assembly) were listed and I was able to select my busines object and drag the fields to the report.
Now every time I go into the add dataset wizard there is nothing in the datasource list. If I add the report to the objects library and create an object datasource then they appear in here fine. Obviously i dont want reports in the objects library, they go in the website.
Does anyone know why the add new datasource option is disabled for Web applications? (Accessed from Data > Add new datasource)
Can anyone tell me how I can use the object datasource in the designer in the report?
my classes i want to report on have both a parameterless constructor, they return a list for the get methods. and they are all serializable.
I have found a solution for this by creating a reporting class library.
if anyone is interested I added it to my blog for future reference.
http://wraithnath.blogspot.com/2011/02/visual-studio-2010-report-viewer-object.html

Applying Unity in dynamic menu

I was going through Unity 2.0 to check if it has an effective use in our new application. My application is a Windows Forms application and uses a traditional bar menu (at the top), currently.
My UIs (Windows Forms) more or less support Dependency Injection pattern since they all work with a class (Presentation Model Class) supplied to them via the constructor. The form then binds to the properties of the supplied P Model class and calls methods on the P Model class to perform its duties. Pretty simple and straightforward.
How P Model reacts to the UI actions and responds to them by co-ordinating with the Domain Class (Business Logic/Model) is irrelevant here and thus not mentioned.
The object creation sequence to show up one UI from menu then goes like this -
Create Business Model instance
Create Presentation Model instance with Business Model instance passed to P Model constructor.
Create UI instance with Presentation Model instance passed to UI constructor.
My present solution:
To show an UI in the method above from my menu I would have to refer all assemblies (Business, PModel, UI) from my Menu class. Considering I have split the modules into a number of physical assemblies, that would be a dificult task to add references to about 60 different assemblies. Also the approach is not very scalable since I would certainly need to release more modules and with this approach I would have to change the source code every time I release a new module.
So primarily to avoid the reference of so many assemblies from my Menu class (assembly) I did as below -
Stored all the dependency described above in a database table (SQL Server), e.g.
ModuleShortCode | BModelAssembly | BModelFullTypeName | PModelAssembly | PModelFullTypeName | UIAssembly | UIFullTypeName
Now used a static class named "Launcher" with a method "Launch" as below -
Launcher.Launch("Discount");
Launcher.Launch("Customers");
The Launcher internally uses data from the dependency table and uses Activator.CreateInstance() to create each of the objects and uses the instance as constructor parameter to the next object being created, till the UI is built. The UI is then shown as a modal dialog. The code inside Launcher is somewhat like -
Form frm = ResolveForm("Discount");
frm.ShowDialog();`
The ResolveForm does the trick of building the chain of objects.
Can Unity help me here?
Now when I did that I did not have enough information on Unity and now that I have studied Unity I think I have been doing more or less the same thing. So I tried to replace my code with Unity.
However, as soon as I started I hit a block. If I try to resolve UI forms in my Menu as
Form customers = myUnityContainer.Resolve<Customers>();
or
Form customers = myUnityContainer.Resolve(typeof(Customers));
Then either way, I need to refer to my UI assembly from my Menu assembly since the target Type "Customers" need to be known for Unity to resolve it. So I am back to same place since I would have to refer all UI assemblies from the Menu assembly. I understand that with Unity I would have to refer fewer assemblies (only UI assemblies) but those references are needed which defeats my objectives below -
Create the chain of objects dynamically without any assembly reference from Menu assembly. This is to avoid Menu source code changing every time I release a new module. My Menu also is built dynamically from a table.
Be able to supply new modules just by supplying the new assemblies and inserting the new Dependency row in the table by a database patch.
At this stage, I have a feeling that I have to do it the way I was doing, i.e. Activator.CreateInstance() to fulfil all my objectives. I need to verify whether the community thinks the same way as me or have a better suggestion to solve the problem.
The post is really long and I sincerely thank you if you come til this point. Waiting for your valuable suggestions.
Rajarshi
As I can see from this code
Form customers = myUnityContainer.Resolve<Customers>();
all your code need to know about the customer - is that it's a Form class. So if you use xml configuration for unity you can do the following:
<type type="Form" mapTo="Customer" name="Customer">
</type>
And then you'll be able to resolve it like this:
Form customers = myUnityContainer.Resolve<Form>("Customer");
and there is no need to refference your UI assembly. Offcourse it should be presented in the bin directory or GAC. In this case if you'll develop new Assembly - all you need is to change config and put in in bin or gac.
If you want to make unity configuration from db then you'll have to add referrence to your ui, becouse you'll have to call Register("Customer").

Resources