How to quickly find document using guid in SharePoint Foundation 2010? - c#

We have multiple content databases and each content database have multiple site collection. Site collection is having document libraries. We are using them to store documents. We have guid (UniqueId) of content database, site collection, document library and uploaded document. Is there any way to quickly find the document using Server Object Model rather than using old approach (using objects SPSite, SPWeb, SPList, SPQuery) ? Can you please provide me any code or link through which I can resolve the above issue ?

I'm afraid you cannot query multiple sites with one single query using SharePoint server object model. What you can do instead is to use "SPSiteDataQuery" which queries ONE site collection and in multiple libraries. read about it here:
MSDN: SPSiteDataQuery
Another option which will not use Server Object Model is to query the SQL Server Database directly (which is not recommended: Five Reasons Not to Directly Query SharePoint Databases). In order to do that you have to query against "All Docs" table in the content database of your web applications, gather the results, and use SiteId, WebId, ListId and ItemId columns and then use Server Object Model to find your document.

Related

How to Query new sites in SharePoint tenant by querying on site creation date with Microsoft Graph API/SDK in C#?

We want to query a SharePoint tenant periodically for any new sites/subsites created since the last time the query was run (e.g. once every 5 minutes).
We are open to running graph queries at the SharePoint tenant level or the SharePoint site collection level.
This tenant has >50,000 sites + subsites in it. Enumerating them all takes too long. So we are hoping to create a graph query that can identify only sites with a creation date within a narrow range so we can make this process faster.
Cany anyone share more information on how to achieve such a query across the tenant, or site collection, for site creation date? Thanks in advance.
The fastest way to list all tenant's sites (large amount) is querying a hidden system list. It requires to have the right permissions to read listitems.
First, list all SP lists via the query: https://graph.microsoft.com/v1.0/sites/<yourtenant>-admin.sharepoint.com/Lists/?select=id,name
Next, via MS graph, you can query and filter the listitems in the list with the displayname DO_NOT_DELETE_SPLIST_TENANTADMIN_ALL_SITES_AGGREGATED_SITECOLLECTIONS as all sites' references are there. You can use the integrated pagination URL in #odata.nextLink property. Read : https://learn.microsoft.com/en-us/graph/paging
Also, another option, via a search query it is possible too :
https://graph.microsoft.com/v1.0/sites?search='<site_name_or_alias>'&filter=createdDateTime ge '2020-10-26T00:00:00Z'.
However, beware of the fact that just a few properties are supported for filtering if you use the search.

Using MS Graph to Read Excel Contents Through Sharepoint

I'm attempting to use MS Graph to parse the contents of excel files and sync the data with other business-line applications. The issue I'm running into is actually getting at the data in excel.
I'm using a ClientCredentialProvider authenticating to an Azure AD App Registration which has FullControl and Read.All permissions in my tenant to create my GraphServiceClient, and can successfully query the Site via ID, and even see the document library I'm trying to access, but the Items comes up empty. See below
var result = _graphService.Client
.Sites["my-site-id"] // This works
.Drives["site-drive-id"] // This works to find the document library
//.Lists["list-id-corresponding-to-folder"] // This also works to find that folder
.Items // ****This is null****
.Request()
.GetAsync()
.Result;
I tried using the Lists property (as noted above) because as I understand it document libraries in SharePoint are really just lists, but again the Items enumeration yields no results.
I can't find documentation on Microsoft's site on this use case, and I notice using the MS Graph Explorer that the returned object doesn't have an "items" field (or many properties in the Microsoft.Graph.Site class), but I would think there is some way to get this field populated since it's implemented in the Microsoft.Graph namespace. Not sure if I'm missing some permissions step or what, but if I can access the site with FullControl I should be able to access all its contents...
I can't use Client.Me (personal drive) as a source location because 1) the application doesn't run under my permissions and 2) there is a need to read multiple files; the idea would be just provide the needed site/drive/item ID's and get the documents.
Is there some other way I should be going about this?
#broccoli_rob,
MS Graph has not exposed the functionality of enumerating all items in a drive. Instead, you can only list children or get item by id.
We suggest you use /drive/root:/{item-path} to get items in a folder. And you can vaild the endpoint in Graph explorer:
BR

Cross database query using database name between shard and master db is not working in sql azure with sharding

I have sharding in SQL Azure.
Basically my structure is like below:
1. Master Database
2. Shard0
3. Shard1
I store all non sharded client into master database but on special request from client, i create seperate shard from them.
While reporting sometimes i need to access master database data from say Shard0.
I have followed all articles available on internet like https://azure.microsoft.com/en-in/documentation/articles/sql-database-elastic-query-vertical-partitioning/
but somehow the [database].[dbo].[tablename] query is not working.
I am using SQL v12 in azure.
You cannot use three part name syntax like above to refer to an external table. You query an external table as if it were a normal local table, i.e., use [schema_name].[external_table_name].
Hope this helps.
Thanks,
Torsten

reporting services and custom datasource

I'm new to reporting services and ask for the possibily of using custom object as datasource? i'm using asp.net, visual web developer 2008 express edition and c#, if yes can you give an example. thanks for help
You can't use POCO as a data source directly in reporting services. There are a few ways to do this.
The simplest it to save your data to a database and query the database.
You could serialize the object to XML and query that by either including the XML directly into your query in an <XmlData> element, or calling a web service to retrieve the XML.
Create an XML Data Source for a Web Service
In your report project, right click on the Shared Data Sources folder.
Select Add New Data Source.
Set the Name to use.
Set the Type to XML.
Set the connection string to http://MyWebServer/MyWebServiceEndpoint.asmx.
Go to the Credentials page.
Configure the authentication.
Click OK.
You'll need to examine the WSDL for the web service and see the following references to help you build the query:
Reporting Services: Using XML and Web Service Data Sources
XML Query Syntax for XML Report Data (SSRS)
Element Path Syntax for XML Report Data (SSRS)
Here's a list of supported data sources from msdn: Data Sources
You would simply add a shared data source to your project (example: MyDataSource.rds) and choose from the available types. There, you would simply supply the appropriate credentials. Each of your reports would use the data source.
EDIT
Here's a simple tutorial on adding a data source: Creating a Shared Data Source in Reporting Services

Linq query combining ADO.Net entities from a database connection and a data service reference?

I'm not even quite sure how to properly word this, but here goes.
I have two .net web applications. One provides a WCF data service ("DEPT_DataService") which provides access to a number of entity sets ("DEPT_Entities"). The other is an MVC2 application which provides a web interface, and also has its own ADO.net entities which are backed by a local MSSQL database.
Using an overly-basic structure to illustrate:
Let's say the WCF data service application includes a single entity set, "Departments", backed by a "Departments" table in its local SQL database. This contains a list of all the departments in the company, along with the employee ID of the primary contact for that department.
Let's also say that the MVC2 application includes a single entity set, "Employees", which contains a list of a bunch of people, including their name and their employee ID.
I've got DEPT_Entities added to the MVC2 application as a Service Reference, "DEPT". When I look at that service reference in the Object Browser, I see "DEPT_Entities" and "Departments".
What I want to do is define a relationship that allows me, via Linq, to refer to something like this:
Employee firstEmployee = db.Employees.First();
Department[] firstEmployeesDepts = firstEmployee.Departments.toList();
...in other words, I essentially want a navigation property that provides a one-to-many relationship between the Employee entities found in the local database and the Department entities found in the remote data service.
Is this doable? How?
Thanks!
If you want to access the databases directly without a webservice:
You can use SQL Server tricks (Remote Query inside of a View to a Linked Server) to make Linq2SQL be able to query the remote table. Essentially, you simulate that the remote table is just an ordinary local table (a view, but L2S does not care).
This will work but it will not be pretty.
If you want to have a webservice in front of one of the tables: This will not work because L2S does not understand webservices.
In fact, I would architecturally advise against hinding the fact that you are calling a webservice.

Categories

Resources