Skip to main content
deleted 6 characters in body
Source Link
Evariste
  • 9.7k
  • 2
  • 21
  • 30

Your idea of mutualizing code is good IMO. I like your OfficeSearch method.
About your consts, you should indent them for better reading.

Regarding the code itself now, mind:

  • Opening new SPSite/SPWeb objects is costly. Consider opening only once and passing these objects as parameters (but don't forget to close them at the end). Or, if you're in a Web context (Web part, page...), you can simply rely on the contextual objects (SPContext.Current.Web) that are already opened for you, and do not require disposing. Also, note they're under the identity of the current user.
  • Instead fof using: SPList myList = currentWeb.Lists[Models.Sol.PB1.ListName]; and thus rely on name of the list, use currentWeb.GetList(SPUrlUtility.CombineUrl(currentWeb.Url, listWebRelativeUrl));

Your idea of mutualizing code is good IMO. I like your OfficeSearch method.
About your consts, you should indent them for better reading.

Regarding the code itself now, mind:

  • Opening new SPSite/SPWeb objects is costly. Consider opening only once and passing these objects as parameters (but don't forget to close them at the end). Or, if you're in a Web context (Web part, page...), you can simply rely on the contextual objects (SPContext.Current.Web) that are already opened for you, and do not require disposing. Also, they're under the identity of the current user.
  • Instead f using: SPList myList = currentWeb.Lists[Models.Sol.PB1.ListName]; and thus rely on name of the list, use currentWeb.GetList(SPUrlUtility.CombineUrl(currentWeb.Url, listWebRelativeUrl));

Your idea of mutualizing code is good IMO. I like your OfficeSearch method.
About your const, you should indent them for better reading.

Regarding the code itself now:

  • Opening new SPSite/SPWeb objects is costly. Consider opening only once and passing these objects as parameters (but don't forget to close them at the end). Or, if you're in a Web context (Web part, page...), you can simply rely on the contextual objects (SPContext.Current.Web) that are already opened for you, and do not require disposing. Also, note they're under the identity of the current user.
  • Instead of using: SPList myList = currentWeb.Lists[Models.Sol.PB1.ListName]; and thus rely on name of the list, use currentWeb.GetList(SPUrlUtility.CombineUrl(currentWeb.Url, listWebRelativeUrl));
added 49 characters in body
Source Link
Evariste
  • 9.7k
  • 2
  • 21
  • 30

Your idea of mutualizing code is good IMO. I like your OfficeSearch method.
About your constconsts, you shoudlshould indent them for better reading.

Regarding the code itself now, mind:

  • Opening new SPSite/SPWeb objects is costly. Consider opening only once and passing these objects as parameters (but don't forget to close them at the end). Or, if you're in a Web context (Web part, page...), you can simply rely on the contextual objects (SPContext.Current.Web) that are already opened for you, and do not require disposingdo not require disposing. Also, they're Underunder the identity of the current user.
  • Instead f using: SPList myList = currentWeb.Lists[Models.Sol.PB1.ListName]; and thus rely on name of the list, use currentWeb.GetList(SPUrlUtilitiesSPUrlUtility.CombineUrl(currentWeb.Url, listWebRelativeUrl));

Your idea of mutualizing code is good IMO. I like your OfficeSearch method.
About your const, you shoudl indent them for better reading.

Regarding the code itself now, mind:

  • Opening new SPSite/SPWeb objects is costly. Consider opening only once and passing these objects as parameters. Or, if you're in a Web context (Web part, page...), you can simply rely on the contextual objects (SPContext.Current.Web) that are already opened for you, and do not require disposing. Also, they're Under the identity of the current user.
  • Instead f using: SPList myList = currentWeb.Lists[Models.Sol.PB1.ListName]; and thus rely on name of the list, use currentWeb.GetList(SPUrlUtilities.CombineUrl(currentWeb.Url, listWebRelativeUrl));

Your idea of mutualizing code is good IMO. I like your OfficeSearch method.
About your consts, you should indent them for better reading.

Regarding the code itself now, mind:

  • Opening new SPSite/SPWeb objects is costly. Consider opening only once and passing these objects as parameters (but don't forget to close them at the end). Or, if you're in a Web context (Web part, page...), you can simply rely on the contextual objects (SPContext.Current.Web) that are already opened for you, and do not require disposing. Also, they're under the identity of the current user.
  • Instead f using: SPList myList = currentWeb.Lists[Models.Sol.PB1.ListName]; and thus rely on name of the list, use currentWeb.GetList(SPUrlUtility.CombineUrl(currentWeb.Url, listWebRelativeUrl));
Source Link
Evariste
  • 9.7k
  • 2
  • 21
  • 30

Your idea of mutualizing code is good IMO. I like your OfficeSearch method.
About your const, you shoudl indent them for better reading.

Regarding the code itself now, mind:

  • Opening new SPSite/SPWeb objects is costly. Consider opening only once and passing these objects as parameters. Or, if you're in a Web context (Web part, page...), you can simply rely on the contextual objects (SPContext.Current.Web) that are already opened for you, and do not require disposing. Also, they're Under the identity of the current user.
  • Instead f using: SPList myList = currentWeb.Lists[Models.Sol.PB1.ListName]; and thus rely on name of the list, use currentWeb.GetList(SPUrlUtilities.CombineUrl(currentWeb.Url, listWebRelativeUrl));