D
David
Hi all,
I am using Linq to SQL and having some lengthy time problems with simple
assignment of values. At first, I thought it was a problem assigning to my
editlabels (these are a server control that will allow a label to become an
edit box... but I have eliminated that)
My linq is...
var sheet = from sheetRow in dc.ServiceSheets.Where( c =>
c.SheetID == Request.QueryString["sheet"])
join trailerRow in dc.TrailerDetails
on sheetRow.TrailerID equals trailerRow.TrailerID into
joinTable
from result in joinTable.DefaultIfEmpty()
join trailerBarcode in dc.TrailerBarcodes
on sheetRow.Barcode equals trailerBarcode.Barcode into
bcTable
from result2 in bcTable.DefaultIfEmpty()
select new
{
Sheet = sheetRow,
Trailer = result,
trBarcode = result2
};
My assignments are:
BarcodesMatch = sheet.First().trBarcode == null ? false
: (sheet.First().Sheet.Barcode == sheet.First().trBarcode.Barcode ?
(sheet.First().Sheet.TrailerID == sheet.First().trBarcode.TrailerID ? true :
false) : false);
string a1 = sheet.First().Trailer.ChassisNo;
string b1 = sheet.First().Trailer.MinistryNo;
string c1 = sheet.First().Trailer.Make;
string d1 = sheet.First().Trailer.Year;
string e1 = sheet.First().Trailer.CustomerFleetNo;
string f1 =
sheet.First().Trailer.MOTExpiry.Value.ToShortDateString();
string g1 = sheet.First().Trailer.ODOReading.ToString();
string h1 =
sheet.First().Trailer.ServiceDue.Value.ToShortDateString();
the string a1 to h1 were being assigned to my edit labels, but it takes just
as long to assign to a string. Just this simple operation is taking
something like 5 seconds... the BarcodesMatch (which is a bool) is taking at
least 2 seconds.
I have set up indexes on my servicesheets, trailerdetails and
trailerbarcodes, though I am not sure if my indexes are correct. I have
extracted the query that the linq generates and run it direct in SSMSE and
it only takes 1 or 2 seconds.
Any ideas on what I might do next to improve the performance? (I have other
parts of the page also taking quite a bit of time, if I can get this fixed,
then perhaps the same fix will also apply elsewhere, though I know that this
area here is the biggest bottleneck)
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
I am using Linq to SQL and having some lengthy time problems with simple
assignment of values. At first, I thought it was a problem assigning to my
editlabels (these are a server control that will allow a label to become an
edit box... but I have eliminated that)
My linq is...
var sheet = from sheetRow in dc.ServiceSheets.Where( c =>
c.SheetID == Request.QueryString["sheet"])
join trailerRow in dc.TrailerDetails
on sheetRow.TrailerID equals trailerRow.TrailerID into
joinTable
from result in joinTable.DefaultIfEmpty()
join trailerBarcode in dc.TrailerBarcodes
on sheetRow.Barcode equals trailerBarcode.Barcode into
bcTable
from result2 in bcTable.DefaultIfEmpty()
select new
{
Sheet = sheetRow,
Trailer = result,
trBarcode = result2
};
My assignments are:
BarcodesMatch = sheet.First().trBarcode == null ? false
: (sheet.First().Sheet.Barcode == sheet.First().trBarcode.Barcode ?
(sheet.First().Sheet.TrailerID == sheet.First().trBarcode.TrailerID ? true :
false) : false);
string a1 = sheet.First().Trailer.ChassisNo;
string b1 = sheet.First().Trailer.MinistryNo;
string c1 = sheet.First().Trailer.Make;
string d1 = sheet.First().Trailer.Year;
string e1 = sheet.First().Trailer.CustomerFleetNo;
string f1 =
sheet.First().Trailer.MOTExpiry.Value.ToShortDateString();
string g1 = sheet.First().Trailer.ODOReading.ToString();
string h1 =
sheet.First().Trailer.ServiceDue.Value.ToShortDateString();
the string a1 to h1 were being assigned to my edit labels, but it takes just
as long to assign to a string. Just this simple operation is taking
something like 5 seconds... the BarcodesMatch (which is a bool) is taking at
least 2 seconds.
I have set up indexes on my servicesheets, trailerdetails and
trailerbarcodes, though I am not sure if my indexes are correct. I have
extracted the query that the linq generates and run it direct in SSMSE and
it only takes 1 or 2 seconds.
Any ideas on what I might do next to improve the performance? (I have other
parts of the page also taking quite a bit of time, if I can get this fixed,
then perhaps the same fix will also apply elsewhere, though I know that this
area here is the biggest bottleneck)
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available