Thursday 15 January 2015

c# - How to load a dictionary only once in WCF serive -


I have a WCF service in which I apply some operational (contractual) contracts. I need to load some values ​​from Excel to Dictionary I can load prices, but loads every time when a member of the service is accessed / consumed.

I do not want to load every time. Its only enough to load once. How to get it

  Public class Service1: IService1 {dictionary & lt; String, list & lt; MappingField & gt; & Gt; MappingCollections; Public service 1 () {mappingclothes = load codes (location, filename); }} #region IService1 member public zero ticket ticket (ticket [] ticket) {............; ............; }    

You can do something like this:

  Fixed dictionary & lt; String, list & lt; MappingField & gt; & Gt; MappingCollections; Public Zero Ticket Tickets (Ticket [] Tickets) {If (Mapping Convolon == blank) MappingClocks = Load Codes (Location, Filename); ...}   

This will examine the existence of an example of mapping collection and if it does not exist, then make it (perhaps different from the utility method).

No comments:

Post a Comment