Beispiel #1
0
        Entity GetOrCreateEntity(dynamic idOrName)
        {
            Entity type;

            if (idOrName is NameExpression)
            {
                type = model.Entities().SingleOrDefault(t => t.Name == idOrName.Value);
            }
            else if (idOrName is IdentifierExpression)
            {
                type = model.Entities().SingleOrDefault(t => t.Identifier == idOrName.Value);
            }
            else
            {
                throw new NotImplementedException();
            }

            if (type == null)
            {
                if (idOrName is NameExpression)
                {
                    type = new Entity(model)
                    {
                        Name = idOrName.Value, Implicit = true
                    }
                }
                ;
                else if (idOrName is IdentifierExpression)
                {
                    type = new Entity(model)
                    {
                        Identifier = idOrName.Value, Implicit = true
                    }
                }
                ;
                else
                {
                    throw new NotImplementedException();
                }

                model.Add(type);
            }
            else
            {
            }

            return(type);
        }