Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to render a dates from list to the ASP Calendar.

My list look like this:

Kontrakt | Pracownik | Dzien | ID | Procenty
--------------------------------------------

I made Linq Query, but it's doing quite long, about 3-4 secunds. How to put indexes on it?

     `   SPWeb witryna = SPContext.Current.Web;
        SPListItemCollection listaDniNaProjektDropDownList = witryna.Lists["Szczegoly"].Items;
        //Link technology
            QumakDataContext qumak = new QumakDataContext("http://gzawistowskilap");
            var szczegoly = from szczegolyQumak in qumak.Szczegoly
                            orderby szczegolyQumak.Dzien 

                            select new {szczegolyQumak.Dzien, szczegolyQumak.Kontrakt};

            foreach(var zmiennaSzczegoly in szczegoly ){

                Label1.Text +=zmiennaSzczegoly.Dzien + zmiennaSzczegoly.Kontrakt + "<br />";
            }`
share|improve this question
    
Hi Grzegorz, have you tried to use a StrinBuilder class to make the string that you want and after put it in Label1.Text ? –  Salvatore Di Fazio Oct 21 '12 at 6:42

1 Answer 1

up vote 1 down vote accepted

Indexes are not created in SPQuery, but you can create indexes on columns involved in joins, where clauses from Indexed Column option:

enter image description here

enter image description here

enter image description here

You can read about Indexing and Query Throttling here

Also, as Salvatore Di Fazio said... replace the above code as below:

SPWeb witryna = SPContext.Current.Web;
SPListItemCollection listaDniNaProjektDropDownList = witryna.Lists["Szczegoly"].Items;
//Link technology
QumakDataContext qumak = new QumakDataContext("http://gzawistowskilap");
var szczegoly = from szczegolyQumak in qumak.Szczegoly
                orderby szczegolyQumak.Dzien 

               select new {szczegolyQumak.Dzien, szczegolyQumak.Kontrakt};
StringBuilder str = new StringBuilder(string.Empty);

foreach(var zmiennaSzczegoly in szczegoly ){
    str.Append(zmiennaSzczegoly.Dzien + zmiennaSzczegoly.Kontrakt + "<br />");
}

Label1.Text = str.ToString();

You will need to add reference as using System.Text;

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.