LINQ2SQL and Crystal Reports

A

Alex Starke

Hi folks,

I play a little bit around with LINQ and found the problem, that I can not
print crystal reports directly from a LINQ query.

Example with a formerly Dataset :

crystal.SetDataSource(dataset);

Now with LINQ :

var products = from p in db.products
select p;

crystal.SetDataSource(products);

This doesn't work. Can anyone explain how to resolve this issue ?

Best regards

Alex
 
J

Jon Skeet [C# MVP]

I play a little bit around with LINQ and found the problem, that I can not
print crystal reports directly from a LINQ query.

Example with a formerly Dataset :

crystal.SetDataSource(dataset);

Now with LINQ :

var products = from p in db.products
select p;

crystal.SetDataSource(products);

This doesn't work. Can anyone explain how to resolve this issue ?

Well, it would really help if you'd give more information. "This
doesn't work" doesn't really give us much to go on.

Jon
 
A

Alex Starke

I'm sorry, but I thought that some else got the same problem and know a
quick solution.

If I do a crystal.SetDataSource(products); I get the following runtime error
:

System.NotSupportedException : "DataSet does not support System.Nullable<>."

So it seems to be clear, that the System.Linq.IQueryable<products> has to be
coverted
to Dataset. But I have no idea how or if there is a better solution.

Best regards
Alex
 
J

Jon Skeet [C# MVP]

Alex Starke said:
I'm sorry, but I thought that some else got the same problem and know a
quick solution.

If I do a crystal.SetDataSource(products); I get the following runtime error
:

System.NotSupportedException : "DataSet does not support System.Nullable<>."

So it seems to be clear, that the System.Linq.IQueryable<products> has to be
coverted to Dataset. But I have no idea how or if there is a better
solution.

That doesn't seem *particularly* clear to me... it's unclear why
DataSet is getting involved at all if you're not creating a DataSet...
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Now with LINQ :

var products = from p in db.products
select p;

crystal.SetDataSource(products);

This doesn't work. Can anyone explain how to resolve this issue ?

Just because SetDataSource receive an object instance it does not mean you
can pass anything. AFAIK you need to pass a DataSet. I'm not sure it can
even use a List<T>.
You have to convert your products collection in a dataset first.
 
A

Alex Starke

That doesn't seem *particularly* clear to me... it's unclear why
DataSet is getting involved at all if you're not creating a DataSet...

This is not clear to me. ;-) The CrystalReports.SetDataSource() just accept
datasets (as far as I know).
But I try to use a System.Nullable<> so crystal doesn't accept this kind of
datasource.
I don't know a better solution insted of cast the System.Nullable<> to a
dataset.
Do you have a better idea ?
 
N

Nicholas Paldino [.NET/C# MVP]

The engine of crystal reports must use a DataSet internally when
converting the results of IEnumerable to something the report can bind to
(which make some sort of sense, since the other overloads of SetDataSource
take a DataSet/DataTable, the implementation ^probably^ does some conversion
on the IEnumerable to a DataSet and then passes it to an overload).
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


At least in the version shipped with 1.1 you have to use a Dataset. So you
had to do the conversion yourself.

I do not thing it was changed in 2.2 though.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Nicholas Paldino said:
The engine of crystal reports must use a DataSet internally when
converting the results of IEnumerable to something the report can bind to
(which make some sort of sense, since the other overloads of SetDataSource
take a DataSet/DataTable, the implementation ^probably^ does some
conversion on the IEnumerable to a DataSet and then passes it to an
overload).
 
V

Victor Ponce

Simply use the ToList method of your query.

crystal.SetDataSource(products.ToList());

SetDataSource takes an IEnumerable parameter also.



Alex Starke wrote:

LINQ2SQL and Crystal Reports
18-Dec-07

Hi folks

I play a little bit around with LINQ and found the problem, that I can no
print crystal reports directly from a LINQ query

Example with a formerly Dataset

crystal.SetDataSource(dataset)

Now with LINQ

var products = from p in db.product
select p

crystal.SetDataSource(products)

This doesn't work. Can anyone explain how to resolve this issue

Best regard

Alex

Previous Posts In This Thread:

LINQ2SQL and Crystal Reports
Hi folks

I play a little bit around with LINQ and found the problem, that I can no
print crystal reports directly from a LINQ query

Example with a formerly Dataset

crystal.SetDataSource(dataset)

Now with LINQ

var products = from p in db.product
select p

crystal.SetDataSource(products)

This doesn't work. Can anyone explain how to resolve this issue

Best regard

Alex

I'm sorry, but I thought that some else got the same problem and know a quick
I'm sorry, but I thought that some else got the same problem and know a
quick solution

If I do a crystal.SetDataSource(products); I get the following runtime error

System.NotSupportedException : "DataSet does not support System.Nullable<>.

So it seems to be clear, that the System.Linq.IQueryable<products> has to be
coverte
to Dataset. But I have no idea how or if there is a better solution

Best regard
Ale


Re: LINQ2SQL and Crystal Reports

That doesn't seem *particularly* clear to me... it's unclear why
DataSet is getting involved at all if you're not creating a DataSet..

--
Jon Skeet - <[email protected]
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skee
World class .NET training in the UK: http://iterativetraining.co.uk

Re: LINQ2SQL and Crystal Reports
Hi

--
Ignacio Machi
http://www.laceupsolutions.co
Mobile & warehouse Solutions

Just because SetDataSource receive an object instance it does not mean you
can pass anything. AFAIK you need to pass a DataSet. I'm not sure it can
even use a List<T>
You have to convert your products collection in a dataset first.

This is not clear to me. ;-) The CrystalReports.
This is not clear to me. ;-) The CrystalReports.SetDataSource() just accept
datasets (as far as I know)
But I try to use a System.Nullable<> so crystal doesn't accept this kind of
datasource
I don't know a better solution insted of cast the System.Nullable<> to a
dataset
Do you have a better idea ?

The engine of crystal reports must use a DataSet internally when converting
The engine of crystal reports must use a DataSet internally when
converting the results of IEnumerable to something the report can bind to
(which make some sort of sense, since the other overloads of SetDataSource
take a DataSet/DataTable, the implementation ^probably^ does some conversion
on the IEnumerable to a DataSet and then passes it to an overload)

--
- Nicholas Paldino [.NET/C# MVP
- (e-mail address removed)


Hi,At least in the version shipped with 1.1 you have to use a Dataset.
Hi

At least in the version shipped with 1.1 you have to use a Dataset. So you
had to do the conversion yourself.

I do not thing it was changed in 2.2 though.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
message
Re: LINQ2SQL and Crystal Reports
Well, it would really help if you would give more information. "This
does not work" does not really give us much to go on.

Jon


Submitted via EggHeadCafe - Software Developer Portal of Choice
DataContractSerializer Basics
http://www.eggheadcafe.com/tutorial...c-94d2f3b1b265/datacontractserializer-ba.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top