Exemple #1
0
        private static EntitySet GetEntitySet(ObjectContext context, string containerName, string entitySetName)
        {
            EnitityUtility.CheckArgumentNotNull(context, "context");

            // if no container is specified, use the default for the context
            containerName = string.IsNullOrEmpty(containerName) ? context.DefaultContainerName : containerName;
            EnitityUtility.CheckArgumentNotNullOrEmpty(containerName, "containerName");

            // ensure the entity container exists
            EntityContainer container;

            if (!context.MetadataWorkspace.TryGetEntityContainer(containerName,
                                                                 DataSpace.CSpace, out container))
            {
                //throw new ArgumentException(String.Format(Messages.Culture, Messages.UnknownEntityContainer, containerName), "containerName");
            }

            EntitySet entitySet;

            if (string.IsNullOrEmpty(entitySetName))
            {
                // if no entity set is specified, try to find a single entity set taking this type
                entitySet = GetDefaultEntitySet(context, container);
            }
            else if (!container.TryGetEntitySetByName(entitySetName, false, out entitySet))
            {
                // ensure the requested entity set exists
                //throw new ArgumentException(String.Format(Messages.Culture, Messages.UnknownEntitySet, entitySetName), "entitySetName");
            }

            return(entitySet);
        }
Exemple #2
0
 private static string QuoteIdentifier(string identifier)
 {
     EnitityUtility.CheckArgumentNotNullOrEmpty(identifier, "identifier");
     return("[" + identifier.Replace("]", "]]") + "]");
 }