Posts Tagged ‘SharePoint’

Determining the NameSpace for an ECT in SharePoint WP

June 4, 2014 2 comments

So the other day, while working on a SharePoint project, I started writing a custom workflow in Visual Studio and I needed to access an ECT programmatically. To date in this project all my WebParts had the usual custom properties to define the NameSpace for the ECT that I needed to access. But suddenly I was in a situation where that information was not available.

So I had to try and find it a different way. After sitting in a debugging session for a bit and interrogating objects and properties, I eventually found it. So in the interest of sharing some code, here it is. Now I couldn’t find a solution online after googling & binging for a bit. And there might be other solutions out there much better than mine.

using (new SPServiceContextScope(SPServiceContext.GetContext(SPContext.Current.Site)))
 var service = Microsoft.SharePoint.Administration.SPFarm.Local.Services.GetValue<BdcService>(String.Empty);
 Microsoft.BusinessData.MetadataModel.IMetadataCatalog catalog = service.GetDatabaseBackedMetadataCatalog(SPServiceContext.Current);

 var tmp = catalog.GetEntities(“Agencies”);
 var _NameSpace = tmp[0].Key;

Now the “Agencies” entity is just an ECT that I know will be there and it is purely used to be able to extract the NameSpace. And there you have it, no more custom properties on my WebParts to configure the NameSpaces for the ECTs.


TechED Africa 2010 is finally here…

October 16, 2010 Leave a comment

Finally, well almost, the day is here. This for me has been a much anticipated event. Not so much as a first time, because it isn’t, but there are some announcements that I’m hoping for which just feels much better when you are there in person.

TechED Africa 2010 this year will be covering lots of SharePoint 2010, Visual Studio 2010, Windows Phone 7, Silverlight and the usual stuff.

Something I am really looking forward to is Kinect. I’ve been following all things Kinect since it’s first leak as Project Natal. Seeing live in action will be great.

So if you are in the area, pop in.

Categories: TechED Tags: , ,