From: Victor on
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 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

Previous Posts In This Thread:

On Tuesday, December 18, 2007 9:00 AM
Alex Starke wrote:

LINQ2SQL and Crystal Reports
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

On Tuesday, December 18, 2007 9:51 AM
Alex Starke wrote:

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
coverted
to Dataset. But I have no idea how or if there is a better solution.

Best regards
Alex

"Jon Skeet [C# MVP]" <skeet(a)pobox.com> schrieb im Newsbeitrag
news:b5fc5d5a-e9e3-4c16-9305-2ef3c4906613(a)w40g2000hsb.googlegroups.com...

On Tuesday, December 18, 2007 10:02 AM
Jon Skeet [C# MVP] wrote:

Re: LINQ2SQL and Crystal Reports
Alex Starke <Astak(a)gmx.de> wrote:

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 - <skeet(a)pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

On Tuesday, December 18, 2007 10:09 AM
Ignacio Machin \( .NET/ C# MVP \) wrote:

Re: LINQ2SQL and Crystal Reports
Hi,


--
Ignacio Machin
http://www.laceupsolutions.com
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.

On Tuesday, December 18, 2007 10:09 AM
Alex Starke wrote:

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 ?

On Tuesday, December 18, 2007 10:14 AM
Nicholas Paldino [.NET/C# MVP] wrote:

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]
- mvp(a)spam.guard.caspershouse.com

"Jon Skeet [C# MVP]" <skeet(a)pobox.com> wrote in message
news:MPG.21d1f14c6718f65871a(a)msnews.microsoft.com...

On Tuesday, December 18, 2007 10:27 AM
Ignacio Machin \( .NET/ C# MVP \) wrote:

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.
"Nicholas Paldino [.NET/C# MVP]" <mvp(a)spam.guard.caspershouse.com> wrote in
message news:48264500-5185-4320-BAC8-35AF34B9A29A(a)microsoft.com...

On Friday, December 21, 2007 3:04 AM
Jon Skeet [C# MVP] wrote:

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/tutorials/aspnet/ad947ce6-cd3e-4647-b69c-94d2f3b1b265/datacontractserializer-ba.aspx