await QueuedTask.Run(() =>
{
Map map = MapView.Active.Map;
Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri(@"C:\Connections\mySDE.sde")));
CIMSqlQueryDataConnection sqldc = new CIMSqlQueryDataConnection()
{
WorkspaceConnectionString = geodatabase.GetConnectionString(),
GeometryType = esriGeometryType.esriGeometryPolygon,
OIDFields = "OBJECTID",
Srid = "102008",
SqlQuery = "select * from MySDE.dbo.STATES",
Dataset = "States"
};
FeatureLayer flyr = (FeatureLayer)LayerFactory.Instance.CreateLayer(sqldc, map, layerName: "States");
});