Exemple #1
0
        private void GenericTableContext_ReadingEntity(object sender, System.Data.Services.Client.ReadingWritingEntityEventArgs e)
        {
            // TODO: Make these statics
            XNamespace AtomNamespace            = "http://www.w3.org/2005/Atom";
            XNamespace AstoriaDataNamespace     = "http://schemas.microsoft.com/ado/2007/08/dataservices";
            XNamespace AstoriaMetadataNamespace = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";

            GenericEntity entity = e.Entity as GenericEntity;

            if (entity == null)
            {
                return;
            }

            entity.SetTableName(e.Data.Element(AtomNamespace + "link").Attribute("title").Value);

            // read each property, type and value in the payload
            //var properties = e.Entity.GetType().GetProperties();
            //where properties.All(pp => pp.Name != p.Name.LocalName)
            var q = from p in e.Data.Element(AtomNamespace + "content")
                    .Element(AstoriaMetadataNamespace + "properties")
                    .Elements()
                    select new
            {
                Name     = p.Name.LocalName,
                IsNull   = string.Equals("true", p.Attribute(AstoriaMetadataNamespace + "null") == null ? null : p.Attribute(AstoriaMetadataNamespace + "null").Value, StringComparison.OrdinalIgnoreCase),
                TypeName = p.Attribute(AstoriaMetadataNamespace + "type") == null ? null : p.Attribute(AstoriaMetadataNamespace + "type").Value,
                p.Value
            };

            foreach (var dp in q)
            {
                entity[dp.Name] = GetType(dp.TypeName);
            }
        }
Exemple #2
0
        private static void context_ReadingEntity(object sender, System.Data.Services.Client.ReadingWritingEntityEventArgs e)
        {
            if (OrderDetailModels == null)
            {
                OrderDetailModels = new List <ExigoService.OrderDetail>();
            }

            var orderDetailModel = ((ExigoService.OrderDetail)((Common.Api.ExigoOData.OrderDetail)e.Entity));

            OrderDetailModels.Add(orderDetailModel);
        }