SlideShare ist ein Scribd-Unternehmen logo
1 von 28
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

Weitere ähnliche Inhalte

Was ist angesagt?

Reliable and Efficient Facebook data processing
Reliable and Efficient Facebook data processingReliable and Efficient Facebook data processing
Reliable and Efficient Facebook data processingAndres 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 AnalysisJen 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 numberAndre 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 ChestAxiell 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ñozPostman
 

Was ist angesagt? (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
 

Andere mochten auch

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-spsbe12BIWUG
 
Social features in SharePoint 2013
Social features in SharePoint 2013Social features in SharePoint 2013
Social features in SharePoint 2013Michael 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 HoustonKunaal 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 GuideMark 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 - SPTechConSPTechCon
 

Andere mochten auch (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
 

Ähnlich wie LINQ to SharePoint

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
 
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 FlinkFabian Hueske
 
[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 QueriesTatvic 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 ManQuek Lilian
 
SharePoint for the .NET Developer
SharePoint for the .NET DeveloperSharePoint for the .NET Developer
SharePoint for the .NET DeveloperJohn 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, StripeHostedbyConfluent
 
Emergent architecture- a casestudy TREDS
Emergent architecture- a casestudy TREDSEmergent architecture- a casestudy TREDS
Emergent architecture- a casestudy TREDSSyed 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 IntegrationJerod 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 IntegrationNordic 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 2017Matt Warren
 
SharePoint 2010 Client Object Model
SharePoint 2010 Client Object ModelSharePoint 2010 Client Object Model
SharePoint 2010 Client Object ModelG. Scott Singleton
 

Ähnlich wie 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 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 ...
 
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...
 
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
 

Mehr von André Vala

RGPD - Testemunho do Mundo Real
RGPD - Testemunho do Mundo RealRGPD - Testemunho do Mundo Real
RGPD - Testemunho do Mundo RealAndré 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 TeamsAndré 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 WebhooksAndré 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 PlannerAndré Vala
 
From Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint WebhooksFrom Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint WebhooksAndré Vala
 
Microsoft Planner Deep Dive
Microsoft Planner Deep DiveMicrosoft Planner Deep Dive
Microsoft Planner Deep DiveAndré Vala
 
SharePoint - Presente e Futuro
SharePoint - Presente e FuturoSharePoint - Presente e Futuro
SharePoint - Presente e FuturoAndré Vala
 
Office 365 Groups Deep Dive
Office 365 Groups Deep DiveOffice 365 Groups Deep Dive
Office 365 Groups Deep DiveAndré Vala
 
Soluções com Office Graph
Soluções com Office GraphSoluções com Office Graph
Soluções com Office GraphAndré 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 2013André Vala
 
User License Enforcement em SharePoint 2013
User License Enforcement em SharePoint 2013User License Enforcement em SharePoint 2013
User License Enforcement em SharePoint 2013André 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 CollectionsAndré Vala
 
Novidades na pesquisa no SharePoint 2013
Novidades na pesquisa no SharePoint 2013Novidades na pesquisa no SharePoint 2013
Novidades na pesquisa no SharePoint 2013André 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 TogetherAndré Vala
 
Federated Authentication in SharePoint 2010
Federated Authentication in SharePoint 2010Federated Authentication in SharePoint 2010
Federated Authentication in SharePoint 2010André 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 2010André 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 2010André Vala
 
SharePoint Deployment
SharePoint DeploymentSharePoint Deployment
SharePoint DeploymentAndré Vala
 

Mehr von 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
 

Kürzlich hochgeladen

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 

Kürzlich hochgeladen (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 

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

Hinweis der Redaktion

  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.