@HammadMuddassir the local server route I'm told will work for you.
The easiest way if you are always using the same data source is to create map package (with the correct settings so the data is not included in the map package). You can then start up a Local Server instance and access the service via Local Server.
Another approach which again uses local server will be to use the EnterpriseGeodatabaseWorkspace class for SDE connections.
Whilst this workflow is supported currently, it isn't current best practice and I can't guarantee it won't be deprecated in the future. Accessing data via a service published in ArcGIS Server has a number of advantages compared to using SDE connections:
- It scales better for larger implementations
- ArcGIS Server Feature Services gives you symbol styles for the data
- Its more secure to use ArcGIS Server rather than allowing direct database access
- You have access to offline workflows and more robust editing workflows