SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 
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
 
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
 
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
 

Similaire à 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 ...
 
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 ...
 
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...
 
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
 

Plus de 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
 

Plus de 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
 

Dernier

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 

Dernier (20)

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 

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

Notes de l'éditeur

  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.