How to get the storage type of an object set

I am trying to filter objects based on their storage types (tables or views).

I have two objects in my test project, one source is a table, and the other source is a view.

<EntitySet Name="Test" EntityType="TestModel.Store.Test" store:Type="Tables" Schema="dbo" />
<EntitySet Name="TestView" EntityType="TestModel.Store.TestView" store:Type="Views" store:Schema="dbo" store:Name="TestView">

The code example above is taken from the SSDL section of the edmx model file.

I think the store: Type information in SSDL is what I need, but I could not find a way to get this value using the entity-framework api.

Any help would be appreciated.

+3
source share
1 answer

Well, you can request metadata in SSDL by looking in SSpace or StoreItemCollection.

i.e.

var sspaceEntitySets = context.MetadataWorkspace
                       .GetItems<EntityContainer>(DataSpace.SSpace)
                       .First().BaseEntitySets.OfType<EntitySet>();
var entitySet = sspaceEntitySets.First();
var tableType = entitySet
.MetadataProperties["http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator:Type"]
.Value.ToString();

, , . (.. , CSpace), , (.. SSpace), CSpace , , Entity , CSpace EntitySet SSpace EntitySet .

, EF CSSPace (.. API MSL- EDMX).

, MSL, , LINQ to XML - .

,

+2

Source: https://habr.com/ru/post/1710949/


All Articles