Pagination in share Point 2013 using rest API - sharepoint

I have one requirement to implement pagination in sharePoint 2013 using rest api.
I am currently using below query string for pagination:
var querystring="?$skiptoken=" + encodeURIComponent('Paged=TRUE&p_SortBehavior=0&p_ID=' + (startItemId-1) + '&$top=' + itemsCount);
It is working fine. But one of my client asking they want to display items and pagination based on order by start date.
I have tried with below querystring:
var querystring="?$skiptoken=" + encodeURIComponent('Paged=TRUE&p_SortBehavior=0&p_ID=' + (startItemId-1) + '&$top=' + itemsCount)+ "&$orderby=startdate ";
If I will give like this its not working. If i will give ID column instead of startdate its working fine.
Can any one suggest how to use startdate column in querystring while using skiptoken?
Thanks in advance

Modify your query like below. This should help.
var querystring="?$skiptoken=" + encodeURIComponent('Paged=TRUE&p_SortBehavior=0&p_ID=' + (startItemId-1) + '&$top=' + itemsCount + '&$orderby=startdate')
Thanks,
Danny
Please remember to mark as answer if it helps or vote if useful.

Related

how to increase azure searching performance

I am new to Azure services. In my project
there is a function to search text words or multiple text words. For example, if I search "best phase", the search should return data that are related "best" and "phase" in my data.
Sample example code below. Note: searchParameters is used to sort and order my data by their date
string searchText = "best phase";
string[] temp = searchText.Contains(" ") ? searchText.Split(' ') : new string[] { searchText};
var documentSearch = _indexClient.Documents.Search("\"" + searchText + "\"^2, \"|" + searchText + "|\", +" + searchText + ", +" + string.Join(", +", temp) , searchParameters);
The current implementation consumes too much time at around 15-20 sec or more. So I need to do searches faster. Any idea how to make it faster :-)
You can use Azure Search as explained here.
You can also use Full-Text Search of SQL Azure as explained here.
To decide which one to use, please read the difference between them on this article.
Hope this helps.

crm 2011 when update a field in account entity there is no change

Well, my problem is the follow. I create a entity. i call this new_logpuntossegmentacin that has a relation 1 to ∞ with account, when i put in the registration plugin message, create i hope that the follow code fill out the field puntosacumulados but nothing happens:
cli is a Account from a List
total is a Decimal
total = total1 + total2 + total3 + total4 + total5 + total6;
cli.new_puntosacumulados.Insert(i, total.ToString());
svcContext.UpdateObject(cli);
svcContext.SaveChanges();
i++;
if (!String.IsNullOrEmpty(total.ToString()))
{
tracingService.Trace("Response = {0}", total.ToString());
}
tracingService.Trace("Done.");
A couple of questions which may give a little more context:-
1) When you say nothing happens, do you mean that the value is not updated in the database or it doesn't appear updated on the form? If the latter then it may be when the plug in is firing (pre vs post).
2) Could you perhaps post the rest of the method as it may be useful to get some context on some of the other parameters, e.g. what is "i" iterating over here?
Thanks

Subsonic:Selfjoin query need

I want to construct the query which is going to be used in .net. Below you can see the sql query, any one can give me the equivalent subsonic query
SELECT DISTINCT
a2.AccountID AS BID,
a2.AccountName AS Brand
FROM
Account a
INNER JOIN Account a2 ON a.ParentID = a2.AccountID
WHERE
a.AccountTypeID = 6
ORDER BY
Brand
Please help me.
SubSonic 2 or 3?
With SubSonic you always have a nice backdoor.
It's called InlineQuery in 2.x and CodingHorror in 3.x
e.g:
var result = DB.Query().ExecuteReader("SELECT DISTINCT
a2.AccountID AS BID,
a2.AccountName AS Brand
FROM Account a
INNER JOIN Account a2 ON a.ParentID = a2.AccountID
WHERE a.AccountTypeID = ?accounttypeid
ORDER BY Brand", 6);
If you want to stay with the fluent interface because of the syntax checking and the sql conversion. Here is another approach I could think of (SubSonic 2.2)
DataTable result = DB.Select(
"a1." + Account.Columns.AccountId + " as BID",
"a2." + Account.Columns.AccountName + " as Brand")
.From(Account.Schema.QualifiedName + " a1")
.InnerJoin(Account.Schema.QualifiedName + " a2",
"a2." + Account.Columns.account_id,
"a1", "a1." + Account.Columns.parent_id)
.Where("a1." + Account.Columns.AccountTypeId).IsEqualTo(6)
.OrderAsc("a2." + Account.Columns.AccountName)
.ExecuteDataSet().Tables[0];
But I never did this and I haven't verified it. But maybe it works.

Getting a log of the SQL SubSonic is using

Linq2SQL has the great Log property to see what the actual SQL statements that it is generating. Does SubSonic 2.2 have something similar to this?
http://www.e-webdevelopers.com/268/view-the-sql-generated-by-subsonic/
SqlQuery sq = new Select()
.From(Item.Schema)
.InnerJoin(ItemStatus.IstIDColumn, Item.ItmStatusColumn)
.InnerJoin(ItemCategory.ItcItemIDColumn, Item.ItmIDColumn)
.WhereExpression("ItmIsEnabled").IsEqualTo(true)
.AndExpression("ItmName").Like("%" + findThis + "%")
.Or(Item.ItmShortDescriptionColumn).Like("%" + findThis + "%")
.Or(Item.ItmItemCodeColumn).Like("%" + findThis + "%")
.Or(Item.ItmLongDescriptionColumn).Like("%" + findThis + "%")
.Paged(pageIndex, PageSize)
.OrderAsc("itmName");
Response.Write(sq.ToString());
Not tested as I'm not infront of my dev box. Hope that helps.
SubSonic 2.2 ActiveRecord has some events you can override, like AfterValidate() and BeforeCommit(). You could use one of those to log the Sql, but you would have to modify your templates so that code ended up in all your classes.
Or just hit up SubSonic\DataProviders\DataService.cs in your local SubSonic source and see if it will work to add your logging events to all of the .Execute* methods.
It is not possible

Calling an SQL function from a Subsonic.Select

I asked the following question on the subsonic forum, but only seemed to get one response, so I thought I'd post up here as well to see if anyone could shed some more light on the problem...
I wish to create the following SQL statement through SubSonic using the Select tool (or Query tool) .. it uses a custom function called "SPLIT()":
SELECT * FROM VwPropertyList
WHERE VwPropertyList.idCreatedBy = 123
AND VwPropertyList.idCounty = 45
AND 29 IN (SELECT Item FROM SPLIT(DistrictGroupList, ','))
(the last part of this SQL uses the SPLIT function)
My subsonic equivalent looks like the following...
Dim mySelect As New SubSonic.Select
mySelect.From(VwPropertyList.Schema)
mySelect.Where(VwPropertyList.Columns.IdCreatedBy).IsEqualTo(123)
mySelect.And(VwPropertyList.Columns.IdCounty).IsEqualTo(45)
mySelect.And(29).In(New SubSonic.Select("Item").From("SPLIT("
&
VwPropertyList.Columns.DistrictGroupList
& ", ',')"))
This doesn't work though due to the last part .. how can I add "AND 29 IN (SELECT Item FROM SPLIT(DistrictGroupList, ','))" into my Subsonic.Select ?
The response I got from the subsonic forum suggested I do away with Subsonic.Select and replace with hard-coded InlineQuery() statements .. like:
Dim SQL as String = "Select " &
VwPropertyList.Columns.Item SQL = SQL
& " From " &
VwPropertyList.Schema.TableName SQL =
SQL & " Where " &
VwPropertyList.Columns.IdCreatedBy & "
= #CreatedBy " SQL = SQL & " And " & VwPropertyList.Columns.IdCounty & " =
#County " SQL = SQL & " And
#DistrictGroup IN (Select Item From
SPLIT(DistrictGroupList,',')"
Items =
SubSonic.InlineQuery().ExecuteTypedList(Of
MyItem)(SQL, 123,45,29)
I would prefer to use SubSonic.Select if possible though so that I can avail of the paging functionality etc.
Any ideas?
You could do John's suggestion or you could write the SQL using our InlineQuery - which allows you to write raw SQL and pass in params:
var qry=new InlineQuery("SELECT * FROM table WHERE column=#param",value)
You could try to use the original query object (pre 2.1) like so (untested, from memory):
Query q = new Query(VwPropertyList.Schema.TableName);
q.WHERE("29 IN (SELECT Item FROM SPLIT(DistrictGroupList, ','))");
// pass q.ExecuteReader() to the Load() method of your view.
I would suggest that you use the original Query object as you are looking to get paging. Inline Query does not have any methods that allow paging.
If you absolutely wanted to use Subsonic.Select you could mesh the two ideas and run an Inline Query to get the list of values and then use a Regular Subsonic.Select and pass the retrieved values to the select case but then you would be making two trips to the db.
On a side note I prefer reading Subsonic.Select statements written using the fluent interface that it is namely
SubSonic.Select.AllColumnsFrom()
.Where(VwPropertyList.Columns.IdCreatedBy).IsEqualTo(123)
.And(VwPropertyList.Columns.IdCounty).IsEqualTo(45)
.ExecuteAsCollection();
thanks for the responses.
I ended up doing InlineQuery and just re-wrote the paging code that's normally produced by Subsonic.Select ... not the best solution but it seems to work.
It would be good if I could have done something like this though:
Dim s As New SubSonic.Select
s.From(VwPropertyList.Schema)
sWhere(VwPropertyList.Columns.IdCreatedBy).IsEqualTo(123)
sAnd(VwPropertyList.Columns.IdCounty).IsEqualTo(45)
s.And(29).In(New
InlineQuery("(SELECT Item FROM
SPLIT(DistrictGroupList, ','))"))

Resources