SlideShare a Scribd company logo
LINQ to SharePoint
André Vala
andre.vala@create.pt
Agenda
• LINQ?
• LINQ to SharePoint?
• Developing with LINQ
• Common Pitfalls
• Performance
• Conclusion
2
LINQ?
3
LINQ PROVIDER DATA SOURCEAPPLICATION
B
C
A
.NET
.NET
QUERY
DATA
Language Integrated Query
LINQ to SQL
using System.Data.Linq;
DataContext db = new DataContext(@”mydatabase.mdf”);
Table<BankAccount> BankAccounts = db.GetTable<BankAccount>();
var query =
from account in BankAccounts
where account.Bank == “Deutsche Bank”
select account;
foreach (BankAccount account in query)
{
Console.WriteLine(“Number: {0}”, account.Number);
} 4
SHAREPOINT
LIST ITEMS
CAML
LINQ to SharePoint?
5
LINQ PROVIDER DATA SOURCEAPPLICATION
B
C
A
.NET
.NET
QUERY
DATA
SHAREPOINT
LINQ PROVIDER
Microsoft.SharePoint.Linq.dll
LINQ to SharePoint
using Microsoft.SharePoint.Linq;
DataContext data = new DataContext(SPContext.Current.Web.Url);
EntityList<BankAccount> BankAccounts =
data.GetList<BankAccount>(“BankAccounts”);
var query =
from account in BankAccounts
where account.Bank == “Deutsche Bank”
select account;
foreach (BankAccount account in query)
{
Console.WriteLine(“Number: {0}”, account.Number);
}
6
DEMO HELLO LINQ!
7
Developing with LINQ
• Entities
• Add Items
• Delete Items
• Recycle Items
• Update Items
• Logging
8
Entities
BankAccount account = new BankAccount()
{
Number = “99100048169”,
Bank = “Deutsche Bank”
};
9
Content Type Entity Class
Column Attribute Member
Entities Manual Definition
[ContentType(Name=“BankAccount”, Id=“0x0104”)]
public partial class BankAccount
{
[Column(Name=“Number”, FieldType=“Text”)]
public string Number { get; set; }
[Column(Name=“Bank”, FieldType=“Text”)]
public string Bank { get; set; }
}
10
Entities Automatic Generation
SPMetal
Tool to generate entities for a set of content types / lists
Where is it?
C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14BIN
How is it used?
SPMetal
/web:http://myserver/myweb
/code:BankAccounts.cs
/namespace:MyApp.SharePoint.Data
11
Add Items
using Microsoft.SharePoint.Linq;
DataContext data = new DataContext(SPContext.Current.Web.Url);
BankAccount account = new BankAccount()
{
Number = “99100048169”,
Bank = “Deutsche Bank”
};
data.BankAccounts.InsertOnSubmit(account);
data.SubmitChanges();
12
Delete Items
using Microsoft.SharePoint.Linq;
DataContext data = new DataContext(SPContext.Current.Web.Url);
foreach (BankAccount account in data.BankAccounts)
{
if (account.Bank == “Deutsche Bank”)
data.BankAccounts.DeleteOnSubmit(account);
}
data.SubmitChanges();
13
Recycle Items
using Microsoft.SharePoint.Linq;
DataContext data = new DataContext(SPContext.Current.Web.Url);
foreach (BankAccount account in data.BankAccounts)
{
if (account.Bank == “Deutsche Bank”)
data.BankAccounts.RecycleOnSubmit(account);
}
data.SubmitChanges();
14
Update Items
using Microsoft.SharePoint.Linq;
DataContext data = new DataContext(SPContext.Current.Web.Url);
foreach (BankAccount account in data.BankAccounts)
{
if (account.Bank == “Deutsche Bank”)
account.Bank = “Bank of America”;
}
data.SubmitChanges();
15
Logging
using Microsoft.SharePoint.Linq;
DataContext data = new DataContext(SPContext.Current.Web.Url);
StringWriter writer = new StringWriter();
data.Log = writer;
// LINQ queries
(...)
string caml = writer.ToString();
16
DEMO LINQING
17
Common Pitfalls
• Anonymous Access
• Display Names
18
Pitfall Anonymous Access
• LINQ to SharePoint has no support for
anonymous access
• There is a workaround but has disadvantages:
– Large performance impact
– Uses RunWithElevatedPrivileges
• Solution: go back to CAML...
19
DEMO ANONYMOUS ACCESS
20
Pitfall Display Names
• SPMetal uses column Display Names to
generate class members
• What happens when the column names have
special characters? Weird things happen…
• How can we solve it?
21
DEMO DISPLAY NAMES
22
Performance
• Object Tracking Enabled
• LINQ vs CAML
23
Performance Object Tracking Enabled
Optimizes the performancein read-only scenarios...
DataContext data = new DataContext(SPContext.Current.Web.Url);
data.ObjectTrackingEnabled = false;
24
Performance LINQ vs CAML
• The LINQ to CAML translation is performed in
real time
• There is a performance penalty
• The generated query can be inefficient
• Not all the operations offered with LINQ are
supported in CAML...
25
DEMO PERFORMANCE
26
Conclusion
LINQ to SharePoint is really simple to use but
not the solution when...
• The code must run on the client
• The solution must support anonymous access
• Performance is paramount
• There are lookup columns that refer to lists in
other web sites of the same site collection
27
Thank You
André Vala
andre.vala@create.pt

More Related Content

What's hot

Reliable and Efficient Facebook data processing
Reliable and Efficient Facebook data processingReliable and Efficient Facebook data processing
Reliable and Efficient Facebook data processing
Andres Buritica
 
Credit Fraud Prevention with Spark and Graph Analysis
Credit Fraud Prevention with Spark and Graph AnalysisCredit Fraud Prevention with Spark and Graph Analysis
Credit Fraud Prevention with Spark and Graph Analysis
Jen Aman
 
Melb nov17 Virtual Entity and auto number
Melb nov17 Virtual Entity and auto numberMelb nov17 Virtual Entity and auto number
Melb nov17 Virtual Entity and auto number
Andre Margono
 
Web Browser Controls in Adlib: The Hidden Diamond in the Adlib Treasure Chest
Web Browser Controls in Adlib: The Hidden Diamond in the Adlib Treasure ChestWeb Browser Controls in Adlib: The Hidden Diamond in the Adlib Treasure Chest
Web Browser Controls in Adlib: The Hidden Diamond in the Adlib Treasure Chest
Axiell ALM
 
GraphQL and Live Queries by Rodrigo Muñoz
GraphQL and Live Queries by Rodrigo MuñozGraphQL and Live Queries by Rodrigo Muñoz
GraphQL and Live Queries by Rodrigo Muñoz
Postman
 

What's hot (6)

Reliable and Efficient Facebook data processing
Reliable and Efficient Facebook data processingReliable and Efficient Facebook data processing
Reliable and Efficient Facebook data processing
 
Credit Fraud Prevention with Spark and Graph Analysis
Credit Fraud Prevention with Spark and Graph AnalysisCredit Fraud Prevention with Spark and Graph Analysis
Credit Fraud Prevention with Spark and Graph Analysis
 
Melb nov17 Virtual Entity and auto number
Melb nov17 Virtual Entity and auto numberMelb nov17 Virtual Entity and auto number
Melb nov17 Virtual Entity and auto number
 
Web Browser Controls in Adlib: The Hidden Diamond in the Adlib Treasure Chest
Web Browser Controls in Adlib: The Hidden Diamond in the Adlib Treasure ChestWeb Browser Controls in Adlib: The Hidden Diamond in the Adlib Treasure Chest
Web Browser Controls in Adlib: The Hidden Diamond in the Adlib Treasure Chest
 
Workflow02
Workflow02Workflow02
Workflow02
 
GraphQL and Live Queries by Rodrigo Muñoz
GraphQL and Live Queries by Rodrigo MuñozGraphQL and Live Queries by Rodrigo Muñoz
GraphQL and Live Queries by Rodrigo Muñoz
 

Viewers also liked

Karine bosch andy-van_steenbergen-caml-spsbe12
Karine bosch andy-van_steenbergen-caml-spsbe12Karine bosch andy-van_steenbergen-caml-spsbe12
Karine bosch andy-van_steenbergen-caml-spsbe12
BIWUG
 
Social features in SharePoint 2013
Social features in SharePoint 2013Social features in SharePoint 2013
Social features in SharePoint 2013
Michael Doyle
 
CSOM (Client Side Object Model). Explained @ SharePoint Saturday Houston
CSOM (Client Side Object Model). Explained @ SharePoint Saturday HoustonCSOM (Client Side Object Model). Explained @ SharePoint Saturday Houston
CSOM (Client Side Object Model). Explained @ SharePoint Saturday Houston
Kunaal Kapoor
 
Biwug 25092012 sp2013_itpro_hans_jaspers
Biwug 25092012 sp2013_itpro_hans_jaspersBiwug 25092012 sp2013_itpro_hans_jaspers
Biwug 25092012 sp2013_itpro_hans_jaspersBIWUG
 
The SharePoint & jQuery Guide
The SharePoint & jQuery GuideThe SharePoint & jQuery Guide
The SharePoint & jQuery Guide
Mark Rackley
 
SharePoint Client Object Model (CSOM)
SharePoint Client Object Model (CSOM)SharePoint Client Object Model (CSOM)
SharePoint Client Object Model (CSOM)
Kashif Imran
 
Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Rob Windsor
 
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechConDeep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
SPTechCon
 

Viewers also liked (8)

Karine bosch andy-van_steenbergen-caml-spsbe12
Karine bosch andy-van_steenbergen-caml-spsbe12Karine bosch andy-van_steenbergen-caml-spsbe12
Karine bosch andy-van_steenbergen-caml-spsbe12
 
Social features in SharePoint 2013
Social features in SharePoint 2013Social features in SharePoint 2013
Social features in SharePoint 2013
 
CSOM (Client Side Object Model). Explained @ SharePoint Saturday Houston
CSOM (Client Side Object Model). Explained @ SharePoint Saturday HoustonCSOM (Client Side Object Model). Explained @ SharePoint Saturday Houston
CSOM (Client Side Object Model). Explained @ SharePoint Saturday Houston
 
Biwug 25092012 sp2013_itpro_hans_jaspers
Biwug 25092012 sp2013_itpro_hans_jaspersBiwug 25092012 sp2013_itpro_hans_jaspers
Biwug 25092012 sp2013_itpro_hans_jaspers
 
The SharePoint & jQuery Guide
The SharePoint & jQuery GuideThe SharePoint & jQuery Guide
The SharePoint & jQuery Guide
 
SharePoint Client Object Model (CSOM)
SharePoint Client Object Model (CSOM)SharePoint Client Object Model (CSOM)
SharePoint Client Object Model (CSOM)
 
Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010
 
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechConDeep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
 

Similar to LINQ to SharePoint

Spug pt linqtosharepoint
Spug pt linqtosharepointSpug pt linqtosharepoint
Spug pt linqtosharepoint
Comunidade Portuguesa de SharePoiint
 
MWLUG 2014: Modern Domino (workshop)
MWLUG 2014: Modern Domino (workshop)MWLUG 2014: Modern Domino (workshop)
MWLUG 2014: Modern Domino (workshop)
Peter Presnell
 
Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...
Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...
Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...
Sparkhound Inc.
 
AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...
AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...
AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...
Lucas Jellema
 
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
Getting value from IoT, Integration and Data Analytics
 
Stream Analytics with SQL on Apache Flink
 Stream Analytics with SQL on Apache Flink Stream Analytics with SQL on Apache Flink
Stream Analytics with SQL on Apache Flink
Fabian Hueske
 
3.0
3.03.0
[Webinar] Interacting with BigQuery and Working with Advanced Queries
[Webinar] Interacting with BigQuery and Working with Advanced Queries[Webinar] Interacting with BigQuery and Working with Advanced Queries
[Webinar] Interacting with BigQuery and Working with Advanced Queries
Tatvic Analytics
 
From a hack to Data Mesh (Devoxx 2022)
From a hack to Data Mesh (Devoxx 2022)From a hack to Data Mesh (Devoxx 2022)
From a hack to Data Mesh (Devoxx 2022)
Simon Maurin
 
Dev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming ManDev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming Man
Quek Lilian
 
SharePoint for the .NET Developer
SharePoint for the .NET DeveloperSharePoint for the .NET Developer
SharePoint for the .NET Developer
John Calvert
 
How to mutate your immutable log | Andrey Falko, Stripe
How to mutate your immutable log | Andrey Falko, StripeHow to mutate your immutable log | Andrey Falko, Stripe
How to mutate your immutable log | Andrey Falko, Stripe
HostedbyConfluent
 
Emergent architecture- a casestudy TREDS
Emergent architecture- a casestudy TREDSEmergent architecture- a casestudy TREDS
Emergent architecture- a casestudy TREDS
Syed Rayhan
 
Spark, GraphX, and Blockchains: Building a Behavioral Analytics Platform for ...
Spark, GraphX, and Blockchains: Building a Behavioral Analytics Platform for ...Spark, GraphX, and Blockchains: Building a Behavioral Analytics Platform for ...
Spark, GraphX, and Blockchains: Building a Behavioral Analytics Platform for ...
Databricks
 
LF_APIStrat17_Breaking a Monolith: In-Place Refactoring with Service-Oriented...
LF_APIStrat17_Breaking a Monolith: In-Place Refactoring with Service-Oriented...LF_APIStrat17_Breaking a Monolith: In-Place Refactoring with Service-Oriented...
LF_APIStrat17_Breaking a Monolith: In-Place Refactoring with Service-Oriented...
LF_APIStrat
 
Breaking a monolith: In-place refactoring with service-oriented architecture ...
Breaking a monolith: In-place refactoring with service-oriented architecture ...Breaking a monolith: In-place refactoring with service-oriented architecture ...
Breaking a monolith: In-place refactoring with service-oriented architecture ...
Ryan M Harrison
 
Why Standards-Based Drivers Offer Better API Integration
Why Standards-Based Drivers Offer Better API IntegrationWhy Standards-Based Drivers Offer Better API Integration
Why Standards-Based Drivers Offer Better API Integration
Jerod Johnson
 
Why Standards-Based Drivers Offer Better API Integration
Why Standards-Based Drivers Offer Better API IntegrationWhy Standards-Based Drivers Offer Better API Integration
Why Standards-Based Drivers Offer Better API Integration
Nordic APIs
 
Microsoft & Open Source - a 'brave new world' - ProgSCon 2017
Microsoft & Open Source - a 'brave new world' - ProgSCon 2017Microsoft & Open Source - a 'brave new world' - ProgSCon 2017
Microsoft & Open Source - a 'brave new world' - ProgSCon 2017
Matt Warren
 
SharePoint 2010 Client Object Model
SharePoint 2010 Client Object ModelSharePoint 2010 Client Object Model
SharePoint 2010 Client Object Model
G. Scott Singleton
 

Similar to LINQ to SharePoint (20)

Spug pt linqtosharepoint
Spug pt linqtosharepointSpug pt linqtosharepoint
Spug pt linqtosharepoint
 
MWLUG 2014: Modern Domino (workshop)
MWLUG 2014: Modern Domino (workshop)MWLUG 2014: Modern Domino (workshop)
MWLUG 2014: Modern Domino (workshop)
 
Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...
Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...
Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...
 
AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...
AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...
AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...
 
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
 
Stream Analytics with SQL on Apache Flink
 Stream Analytics with SQL on Apache Flink Stream Analytics with SQL on Apache Flink
Stream Analytics with SQL on Apache Flink
 
3.0
3.03.0
3.0
 
[Webinar] Interacting with BigQuery and Working with Advanced Queries
[Webinar] Interacting with BigQuery and Working with Advanced Queries[Webinar] Interacting with BigQuery and Working with Advanced Queries
[Webinar] Interacting with BigQuery and Working with Advanced Queries
 
From a hack to Data Mesh (Devoxx 2022)
From a hack to Data Mesh (Devoxx 2022)From a hack to Data Mesh (Devoxx 2022)
From a hack to Data Mesh (Devoxx 2022)
 
Dev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming ManDev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming Man
 
SharePoint for the .NET Developer
SharePoint for the .NET DeveloperSharePoint for the .NET Developer
SharePoint for the .NET Developer
 
How to mutate your immutable log | Andrey Falko, Stripe
How to mutate your immutable log | Andrey Falko, StripeHow to mutate your immutable log | Andrey Falko, Stripe
How to mutate your immutable log | Andrey Falko, Stripe
 
Emergent architecture- a casestudy TREDS
Emergent architecture- a casestudy TREDSEmergent architecture- a casestudy TREDS
Emergent architecture- a casestudy TREDS
 
Spark, GraphX, and Blockchains: Building a Behavioral Analytics Platform for ...
Spark, GraphX, and Blockchains: Building a Behavioral Analytics Platform for ...Spark, GraphX, and Blockchains: Building a Behavioral Analytics Platform for ...
Spark, GraphX, and Blockchains: Building a Behavioral Analytics Platform for ...
 
LF_APIStrat17_Breaking a Monolith: In-Place Refactoring with Service-Oriented...
LF_APIStrat17_Breaking a Monolith: In-Place Refactoring with Service-Oriented...LF_APIStrat17_Breaking a Monolith: In-Place Refactoring with Service-Oriented...
LF_APIStrat17_Breaking a Monolith: In-Place Refactoring with Service-Oriented...
 
Breaking a monolith: In-place refactoring with service-oriented architecture ...
Breaking a monolith: In-place refactoring with service-oriented architecture ...Breaking a monolith: In-place refactoring with service-oriented architecture ...
Breaking a monolith: In-place refactoring with service-oriented architecture ...
 
Why Standards-Based Drivers Offer Better API Integration
Why Standards-Based Drivers Offer Better API IntegrationWhy Standards-Based Drivers Offer Better API Integration
Why Standards-Based Drivers Offer Better API Integration
 
Why Standards-Based Drivers Offer Better API Integration
Why Standards-Based Drivers Offer Better API IntegrationWhy Standards-Based Drivers Offer Better API Integration
Why Standards-Based Drivers Offer Better API Integration
 
Microsoft & Open Source - a 'brave new world' - ProgSCon 2017
Microsoft & Open Source - a 'brave new world' - ProgSCon 2017Microsoft & Open Source - a 'brave new world' - ProgSCon 2017
Microsoft & Open Source - a 'brave new world' - ProgSCon 2017
 
SharePoint 2010 Client Object Model
SharePoint 2010 Client Object ModelSharePoint 2010 Client Object Model
SharePoint 2010 Client Object Model
 

More from André Vala

RGPD - Testemunho do Mundo Real
RGPD - Testemunho do Mundo RealRGPD - Testemunho do Mundo Real
RGPD - Testemunho do Mundo Real
André Vala
 
Office Dev Day 2018 - Extending Microsoft Teams
Office Dev Day 2018 - Extending Microsoft TeamsOffice Dev Day 2018 - Extending Microsoft Teams
Office Dev Day 2018 - Extending Microsoft Teams
André Vala
 
From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)
From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)
From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)
André Vala
 
From Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint WebhooksFrom Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint Webhooks
André Vala
 
Planning the Death Star with Microsoft Planner
Planning the Death Star with Microsoft PlannerPlanning the Death Star with Microsoft Planner
Planning the Death Star with Microsoft Planner
André Vala
 
From Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint WebhooksFrom Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint Webhooks
André Vala
 
Microsoft Planner Deep Dive
Microsoft Planner Deep DiveMicrosoft Planner Deep Dive
Microsoft Planner Deep Dive
André Vala
 
SharePoint - Presente e Futuro
SharePoint - Presente e FuturoSharePoint - Presente e Futuro
SharePoint - Presente e Futuro
André Vala
 
Office 365 Groups Deep Dive
Office 365 Groups Deep DiveOffice 365 Groups Deep Dive
Office 365 Groups Deep Dive
André Vala
 
Soluções com Office Graph
Soluções com Office GraphSoluções com Office Graph
Soluções com Office Graph
André Vala
 
Host-Named Site Collections in SharePoint 2013
Host-Named Site Collections in SharePoint 2013Host-Named Site Collections in SharePoint 2013
Host-Named Site Collections in SharePoint 2013
André Vala
 
User License Enforcement em SharePoint 2013
User License Enforcement em SharePoint 2013User License Enforcement em SharePoint 2013
User License Enforcement em SharePoint 2013
André Vala
 
How To Use Host-Named Site Collections
How To Use Host-Named Site CollectionsHow To Use Host-Named Site Collections
How To Use Host-Named Site Collections
André Vala
 
Novidades na pesquisa no SharePoint 2013
Novidades na pesquisa no SharePoint 2013Novidades na pesquisa no SharePoint 2013
Novidades na pesquisa no SharePoint 2013
André Vala
 
Building Public Web Sites in SharePoint 2010
Building Public Web Sites in SharePoint 2010 Building Public Web Sites in SharePoint 2010
Building Public Web Sites in SharePoint 2010
André Vala
 
SharePoint + Azure = Better Together
SharePoint + Azure = Better TogetherSharePoint + Azure = Better Together
SharePoint + Azure = Better Together
André Vala
 
Federated Authentication in SharePoint 2010
Federated Authentication in SharePoint 2010Federated Authentication in SharePoint 2010
Federated Authentication in SharePoint 2010
André Vala
 
Using BCS to integrate Azure Services with SharePoint 2010
Using BCS to integrate Azure Services with SharePoint 2010Using BCS to integrate Azure Services with SharePoint 2010
Using BCS to integrate Azure Services with SharePoint 2010
André Vala
 
Solução de Negócio baseadas em Office 2010 e SharePoint 2010
Solução de Negócio baseadas em Office 2010 e SharePoint 2010Solução de Negócio baseadas em Office 2010 e SharePoint 2010
Solução de Negócio baseadas em Office 2010 e SharePoint 2010
André Vala
 
SharePoint Deployment
SharePoint DeploymentSharePoint Deployment
SharePoint Deployment
André Vala
 

More from André Vala (20)

RGPD - Testemunho do Mundo Real
RGPD - Testemunho do Mundo RealRGPD - Testemunho do Mundo Real
RGPD - Testemunho do Mundo Real
 
Office Dev Day 2018 - Extending Microsoft Teams
Office Dev Day 2018 - Extending Microsoft TeamsOffice Dev Day 2018 - Extending Microsoft Teams
Office Dev Day 2018 - Extending Microsoft Teams
 
From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)
From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)
From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)
 
From Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint WebhooksFrom Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint Webhooks
 
Planning the Death Star with Microsoft Planner
Planning the Death Star with Microsoft PlannerPlanning the Death Star with Microsoft Planner
Planning the Death Star with Microsoft Planner
 
From Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint WebhooksFrom Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint Webhooks
 
Microsoft Planner Deep Dive
Microsoft Planner Deep DiveMicrosoft Planner Deep Dive
Microsoft Planner Deep Dive
 
SharePoint - Presente e Futuro
SharePoint - Presente e FuturoSharePoint - Presente e Futuro
SharePoint - Presente e Futuro
 
Office 365 Groups Deep Dive
Office 365 Groups Deep DiveOffice 365 Groups Deep Dive
Office 365 Groups Deep Dive
 
Soluções com Office Graph
Soluções com Office GraphSoluções com Office Graph
Soluções com Office Graph
 
Host-Named Site Collections in SharePoint 2013
Host-Named Site Collections in SharePoint 2013Host-Named Site Collections in SharePoint 2013
Host-Named Site Collections in SharePoint 2013
 
User License Enforcement em SharePoint 2013
User License Enforcement em SharePoint 2013User License Enforcement em SharePoint 2013
User License Enforcement em SharePoint 2013
 
How To Use Host-Named Site Collections
How To Use Host-Named Site CollectionsHow To Use Host-Named Site Collections
How To Use Host-Named Site Collections
 
Novidades na pesquisa no SharePoint 2013
Novidades na pesquisa no SharePoint 2013Novidades na pesquisa no SharePoint 2013
Novidades na pesquisa no SharePoint 2013
 
Building Public Web Sites in SharePoint 2010
Building Public Web Sites in SharePoint 2010 Building Public Web Sites in SharePoint 2010
Building Public Web Sites in SharePoint 2010
 
SharePoint + Azure = Better Together
SharePoint + Azure = Better TogetherSharePoint + Azure = Better Together
SharePoint + Azure = Better Together
 
Federated Authentication in SharePoint 2010
Federated Authentication in SharePoint 2010Federated Authentication in SharePoint 2010
Federated Authentication in SharePoint 2010
 
Using BCS to integrate Azure Services with SharePoint 2010
Using BCS to integrate Azure Services with SharePoint 2010Using BCS to integrate Azure Services with SharePoint 2010
Using BCS to integrate Azure Services with SharePoint 2010
 
Solução de Negócio baseadas em Office 2010 e SharePoint 2010
Solução de Negócio baseadas em Office 2010 e SharePoint 2010Solução de Negócio baseadas em Office 2010 e SharePoint 2010
Solução de Negócio baseadas em Office 2010 e SharePoint 2010
 
SharePoint Deployment
SharePoint DeploymentSharePoint Deployment
SharePoint Deployment
 

Recently uploaded

How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
XfilesPro
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
NaapbooksPrivateLimi
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 

Recently uploaded (20)

How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 

LINQ to SharePoint

  • 1. LINQ to SharePoint André Vala andre.vala@create.pt
  • 2. Agenda • LINQ? • LINQ to SharePoint? • Developing with LINQ • Common Pitfalls • Performance • Conclusion 2
  • 3. LINQ? 3 LINQ PROVIDER DATA SOURCEAPPLICATION B C A .NET .NET QUERY DATA Language Integrated Query
  • 4. LINQ to SQL using System.Data.Linq; DataContext db = new DataContext(@”mydatabase.mdf”); Table<BankAccount> BankAccounts = db.GetTable<BankAccount>(); var query = from account in BankAccounts where account.Bank == “Deutsche Bank” select account; foreach (BankAccount account in query) { Console.WriteLine(“Number: {0}”, account.Number); } 4
  • 5. SHAREPOINT LIST ITEMS CAML LINQ to SharePoint? 5 LINQ PROVIDER DATA SOURCEAPPLICATION B C A .NET .NET QUERY DATA SHAREPOINT LINQ PROVIDER Microsoft.SharePoint.Linq.dll
  • 6. LINQ to SharePoint using Microsoft.SharePoint.Linq; DataContext data = new DataContext(SPContext.Current.Web.Url); EntityList<BankAccount> BankAccounts = data.GetList<BankAccount>(“BankAccounts”); var query = from account in BankAccounts where account.Bank == “Deutsche Bank” select account; foreach (BankAccount account in query) { Console.WriteLine(“Number: {0}”, account.Number); } 6
  • 8. Developing with LINQ • Entities • Add Items • Delete Items • Recycle Items • Update Items • Logging 8
  • 9. Entities BankAccount account = new BankAccount() { Number = “99100048169”, Bank = “Deutsche Bank” }; 9 Content Type Entity Class Column Attribute Member
  • 10. Entities Manual Definition [ContentType(Name=“BankAccount”, Id=“0x0104”)] public partial class BankAccount { [Column(Name=“Number”, FieldType=“Text”)] public string Number { get; set; } [Column(Name=“Bank”, FieldType=“Text”)] public string Bank { get; set; } } 10
  • 11. Entities Automatic Generation SPMetal Tool to generate entities for a set of content types / lists Where is it? C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14BIN How is it used? SPMetal /web:http://myserver/myweb /code:BankAccounts.cs /namespace:MyApp.SharePoint.Data 11
  • 12. Add Items using Microsoft.SharePoint.Linq; DataContext data = new DataContext(SPContext.Current.Web.Url); BankAccount account = new BankAccount() { Number = “99100048169”, Bank = “Deutsche Bank” }; data.BankAccounts.InsertOnSubmit(account); data.SubmitChanges(); 12
  • 13. Delete Items using Microsoft.SharePoint.Linq; DataContext data = new DataContext(SPContext.Current.Web.Url); foreach (BankAccount account in data.BankAccounts) { if (account.Bank == “Deutsche Bank”) data.BankAccounts.DeleteOnSubmit(account); } data.SubmitChanges(); 13
  • 14. Recycle Items using Microsoft.SharePoint.Linq; DataContext data = new DataContext(SPContext.Current.Web.Url); foreach (BankAccount account in data.BankAccounts) { if (account.Bank == “Deutsche Bank”) data.BankAccounts.RecycleOnSubmit(account); } data.SubmitChanges(); 14
  • 15. Update Items using Microsoft.SharePoint.Linq; DataContext data = new DataContext(SPContext.Current.Web.Url); foreach (BankAccount account in data.BankAccounts) { if (account.Bank == “Deutsche Bank”) account.Bank = “Bank of America”; } data.SubmitChanges(); 15
  • 16. Logging using Microsoft.SharePoint.Linq; DataContext data = new DataContext(SPContext.Current.Web.Url); StringWriter writer = new StringWriter(); data.Log = writer; // LINQ queries (...) string caml = writer.ToString(); 16
  • 18. Common Pitfalls • Anonymous Access • Display Names 18
  • 19. Pitfall Anonymous Access • LINQ to SharePoint has no support for anonymous access • There is a workaround but has disadvantages: – Large performance impact – Uses RunWithElevatedPrivileges • Solution: go back to CAML... 19
  • 21. Pitfall Display Names • SPMetal uses column Display Names to generate class members • What happens when the column names have special characters? Weird things happen… • How can we solve it? 21
  • 23. Performance • Object Tracking Enabled • LINQ vs CAML 23
  • 24. Performance Object Tracking Enabled Optimizes the performancein read-only scenarios... DataContext data = new DataContext(SPContext.Current.Web.Url); data.ObjectTrackingEnabled = false; 24
  • 25. Performance LINQ vs CAML • The LINQ to CAML translation is performed in real time • There is a performance penalty • The generated query can be inefficient • Not all the operations offered with LINQ are supported in CAML... 25
  • 27. Conclusion LINQ to SharePoint is really simple to use but not the solution when... • The code must run on the client • The solution must support anonymous access • Performance is paramount • There are lookup columns that refer to lists in other web sites of the same site collection 27

Editor's Notes

  1. This demo shows how to build a simple LINQ query to retrieve data from a SharePoint list.
  2. This demos shows the basics of using LINQ to SharePoint to Add, Update, Delete and Recycle list items.
  3. This demos shows why Anonymous Acess is not supported in LINQ to SharePoint and how you can get around it.
  4. This demo shows how to generate entities with SPMetal without using the column display names.
  5. This demo shows how LINQ to SharePoint compares to CAML performance-wise.