private static void BuildOrderss(IEdmModel model) { IEdmEntityType orderType = model.SchemaElements.OfType<IEdmEntityType>().First(e => e.Name == "Order"); Guid[] guids = { new Guid("196B3584-EF3D-41FD-90B4-76D59F9B929C"), new Guid("6CED5600-28BA-40EE-A2DF-E80AFADBE6C7"), new Guid("75036B94-C836-4946-8CC8-054CF54060EC"), new Guid("B3FF5460-6E77-4678-B959-DCC1C4937FA7"), new Guid("ED773C85-4E3C-4FC4-A3E9-9F1DA0A626DA") }; IEdmEntityObject[] untypedOrders = new IEdmEntityObject[5]; for (int i = 0; i < 5; i++) { dynamic untypedOrder = new EdmEntityObject(orderType); untypedOrder.OrderId = i; untypedOrder.Name = string.Format("Order-{0}", i); untypedOrder.Token = guids[i]; untypedOrder.Amount = 10 + i; untypedOrders[i] = untypedOrder; } IEdmCollectionTypeReference entityCollectionType = new EdmCollectionTypeReference( new EdmCollectionType( new EdmEntityTypeReference(orderType, isNullable: false))); Orders = new EdmEntityObjectCollection(entityCollectionType, untypedOrders.ToList()); }
private static void BuildCustomers(IEdmModel model) { IEdmEntityType customerType = model.SchemaElements.OfType<IEdmEntityType>().First(e => e.Name == "Customer"); IEdmEntityObject[] untypedCustomers = new IEdmEntityObject[6]; for (int i = 1; i <= 5; i++) { dynamic untypedCustomer = new EdmEntityObject(customerType); untypedCustomer.ID = i; untypedCustomer.Name = string.Format("Name {0}", i); untypedCustomer.SSN = "SSN-" + i + "-" + (100 + i); untypedCustomers[i-1] = untypedCustomer; } // create a special customer for "PATCH" dynamic customer = new EdmEntityObject(customerType); customer.ID = 6; customer.Name = "Name 6"; customer.SSN = "SSN-6-T-006"; untypedCustomers[5] = customer; IEdmCollectionTypeReference entityCollectionType = new EdmCollectionTypeReference( new EdmCollectionType( new EdmEntityTypeReference(customerType, isNullable: false))); Customers = new EdmEntityObjectCollection(entityCollectionType, untypedCustomers.ToList()); }
private static void BuildOrderss(IEdmModel model) { IEdmEntityType orderType = model.SchemaElements.OfType <IEdmEntityType>().First(e => e.Name == "Order"); Guid[] guids = { new Guid("196B3584-EF3D-41FD-90B4-76D59F9B929C"), new Guid("6CED5600-28BA-40EE-A2DF-E80AFADBE6C7"), new Guid("75036B94-C836-4946-8CC8-054CF54060EC"), new Guid("B3FF5460-6E77-4678-B959-DCC1C4937FA7"), new Guid("ED773C85-4E3C-4FC4-A3E9-9F1DA0A626DA") }; IEdmEntityObject[] untypedOrders = new IEdmEntityObject[5]; for (int i = 0; i < 5; i++) { dynamic untypedOrder = new EdmEntityObject(orderType); untypedOrder.OrderId = i; untypedOrder.Name = string.Format("Order-{0}", i); untypedOrder.Token = guids[i]; untypedOrder.Amount = 10 + i; untypedOrders[i] = untypedOrder; } IEdmCollectionTypeReference entityCollectionType = new EdmCollectionTypeReference( new EdmCollectionType( new EdmEntityTypeReference(orderType, isNullable: false))); Orders = new EdmEntityObjectCollection(entityCollectionType, untypedOrders.ToList()); }
private static void BuildCustomers(IEdmModel model) { IEdmEntityType customerType = model.SchemaElements.OfType <IEdmEntityType>().First(e => e.Name == "Customer"); IEdmEntityObject[] untypedCustomers = new IEdmEntityObject[6]; for (int i = 1; i <= 5; i++) { dynamic untypedCustomer = new EdmEntityObject(customerType); untypedCustomer.ID = i; untypedCustomer.Name = string.Format("Name {0}", i); untypedCustomer.SSN = "SSN-" + i + "-" + (100 + i); untypedCustomers[i - 1] = untypedCustomer; } // create a special customer for "PATCH" dynamic customer = new EdmEntityObject(customerType); customer.ID = 6; customer.Name = "Name 6"; customer.SSN = "SSN-6-T-006"; untypedCustomers[5] = customer; IEdmCollectionTypeReference entityCollectionType = new EdmCollectionTypeReference( new EdmCollectionType( new EdmEntityTypeReference(customerType, isNullable: false))); Customers = new EdmEntityObjectCollection(entityCollectionType, untypedCustomers.ToList()); }
public IHttpActionResult PatchCustomerBySSN([FromODataUri] string ssnKey, EdmEntityObject delta) { IList <string> changedPropertyNames = delta.GetChangedPropertyNames().ToList(); IEdmEntityObject originalCustomer = null; foreach (var customer in AlternateKeysDataSource.Customers) { object value; if (customer.TryGetPropertyValue("SSN", out value)) { string stringKey = (string)value; if (ssnKey == stringKey) { originalCustomer = customer; } } } if (originalCustomer == null) { return(NotFound()); } object nameValue; delta.TryGetPropertyValue("Name", out nameValue); //Assert.NotNull(nameValue); //string strName = Assert.IsType<string>(nameValue); dynamic original = originalCustomer; //original.Name = strName; original.Name = nameValue; return(Ok(originalCustomer)); }
// odata/{datasource}/{entityset}({key})/{navigation} public IActionResult GetNavigation(string datasource, string key, string navigation) { ODataPath path = Request.ODataFeature().Path; NavigationPropertySegment property = path.Last() as NavigationPropertySegment; if (property == null) { return(BadRequest("Not the correct navigation property access request!")); } IEdmEntityType entityType = property.NavigationProperty.DeclaringType as IEdmEntityType; EdmEntityObject entity = new EdmEntityObject(entityType); IDataSource ds = _provider.DataSources[datasource]; ds.Get(key, entity); object value = ds.GetProperty(navigation, entity); if (value == null) { return(NotFound()); } IEdmEntityObject nav = value as IEdmEntityObject; if (nav == null) { return(NotFound()); } return(Ok(nav)); }
public IEdmEntityObject GetProduct(int key) { object id; IEdmEntityObject product = Products.Single(p => HasId(p, key)); return(product); }
public IActionResult Get(int key) { IEdmEntityObject movie = DataSource.GetMovie(key); if (movie != null) { return(Ok(movie)); } return(NotFound()); }
private EntityInstanceContext(ODataSerializerContext serializerContext, IEdmEntityTypeReference entityType, IEdmEntityObject edmObject) { if (serializerContext == null) { throw Error.ArgumentNull("serializerContext"); } SerializerContext = serializerContext; EntityType = entityType.EntityDefinition(); EdmObject = edmObject; }
public IHttpActionResult Post(IEdmEntityObject customer) { if (!ModelState.IsValid) { return(BadRequest("customer is null")); } postedCustomer = customer; object id; customer.TryGetPropertyValue("Id", out id); return(Created(Url.CreateODataLink(new EntitySetPathSegment("UntypedCustomer"), new KeyValuePathSegment(id.ToString())), customer)); }
public IEdmEntityObject Post(IEdmEntityObject entity) { // Get Edm type from request. ODataPath path = Request.ODataProperties().Path; IEdmType edmType = path.EdmType; Contract.Assert(edmType.TypeKind == EdmTypeKind.Collection); IEdmEntityTypeReference entityType = (edmType as IEdmCollectionType).ElementType.AsEntity(); // Do something with the entity object here. return entity; }
public IActionResult GetLocations(int key) { IEdmEntityObject movie = DataSource.GetMovie(key); if (movie != null) { if (movie.TryGetPropertyValue("Locations", out object value)) { return(Ok((EdmComplexObjectCollection)value)); } } return(NotFound()); }
public IActionResult Post([FromBody]IEdmEntityObject customer) { if (!ModelState.IsValid) { return BadRequest("customer is null"); } postedCustomer = customer; object id; customer.TryGetPropertyValue("Id", out id); IEdmEntitySet entitySet = Request.GetModel().EntityContainer.FindEntitySet("TypelessCustomers"); return Created(Request.CreateODataLink(new EntitySetSegment(entitySet), new KeySegment(new[] { new KeyValuePair<string, object>("Id", id) }, entitySet.EntityType(), null)), customer); }
public IEdmEntityObject Post([FromBody] IEdmEntityObject entity) { // Get Edm type from request. ODataPath path = Request.ODataFeature().Path; IEdmType edmType = path.EdmType; Contract.Assert(edmType.TypeKind == EdmTypeKind.Collection); IEdmEntityTypeReference entityType = (edmType as IEdmCollectionType).ElementType.AsEntity(); // Do something with the entity object here. return(entity); }
protected object GetPropertyValue(IEdmEntityObject p, string attributeName, object attributeValue) { if (attributeValue != null) { //specific null handling coz Equals and other aspects would need this return(attributeValue != null ? attributeValue : "--NULL--"); } else { p.TryGetPropertyValue(attributeName, out object value); //specific null handling coz Equals and other aspects would need this return(value != null ? value : "--NULL--"); } }
public IEdmEntityObject GetCategoryFromProduct(int key) { IEdmEntityObject product = Products.Single(p => HasId(p, key)); object category; if (product.TryGetPropertyValue("Category", out category)) { return((IEdmEntityObject)category); } else { return(null); } }
public IHttpActionResult Patch(int key, IEdmEntityObject entity) { object value; if (entity.TryGetPropertyValue("Name", out value)) { string name = value as string; if (name != null) { if (name == "Sam") { return(Ok(name)); } } } return(BadRequest("Not My input.")); }
private static IEdmEntityObject AsEdmEntityObject(object entityInstance, IEdmEntityTypeReference entityType) { if (entityType == null) { throw Error.ArgumentNull("entityType"); } IEdmEntityObject edmEntityObject = entityInstance as IEdmEntityObject; if (edmEntityObject != null) { return(edmEntityObject); } else { return(new TypedEdmEntityObject(entityInstance, entityType)); } }
public IActionResult GetNavigation(string key, string navigation) { //var odataServiceEntity = GetServiceEntity(); if (!IsCurrentUserAuthorized()) { return(Unauthorized()); } ODataPath path = Request.ODataFeature().Path; if (path.PathTemplate != "~/entityset/key/navigation") { return(BadRequest("Not the correct navigation property access request!")); } dynamic property = path.Segments.Last(); if (property == null) { return(BadRequest("Not the correct navigation property access request!")); } IEdmEntityType entityType = property.NavigationProperty.DeclaringType as IEdmEntityType; EdmEntityObject entity = new EdmEntityObject(entityType); var dataSource = GetDataSource(); var value = dataSource.GetProperty(navigation, entity); if (value == null) { return(NotFound()); } IEdmEntityObject nav = value as IEdmEntityObject; if (nav == null) { return(NotFound()); } return(Ok(nav)); }
private IEdmEntityObject GetEdmEntityObject() { if (Request.ContentLength == 0) { return(null); } var ds = HttpContext.ODataFeature().RequestContainer.GetService(typeof(IDataSource)) as IDataSource; var path = Request.ODataFeature().Path; IEdmTypeReference edmTypeReference = null; if (path.EdmType is EdmCollectionType edmType) { edmTypeReference = edmType.ElementType; } else { if (path.EdmType is EdmEntityType edmEntityType) { edmTypeReference = new EdmEntityTypeReference(edmEntityType, false); } } if (edmTypeReference == null) { return(null); } var p = HttpContext.ODataFeature().RequestContainer.GetService(typeof(ODataDeserializerProvider)) as DefaultODataDeserializerProvider; var deserializer = p.GetEdmTypeDeserializer(edmTypeReference) as ODataResourceDeserializer; InMemoryMessage message = new InMemoryMessage(Request); ODataMessageReaderSettings settings = new ODataMessageReaderSettings(); ODataMessageReader reader = new ODataMessageReader((IODataRequestMessage)message, settings, ds.Model); IEdmEntityObject entity = deserializer.Read(reader, typeof(EdmEntityObject), new ODataDeserializerContext() { Model = ds.Model, Request = Request, Path = path, ResourceType = typeof(EdmEntityObject) }) as IEdmEntityObject; return(entity); }
private static void BuildPeople(IEdmModel model) { IEdmEntityType personType = model.SchemaElements.OfType <IEdmEntityType>().First(e => e.Name == "Person"); IEdmEntityObject[] untypedPeople = new IEdmEntityObject[5]; for (int i = 0; i < 5; i++) { dynamic untypedPerson = new EdmEntityObject(personType); untypedPerson.ID = i; untypedPerson.Country_Region = new[] { "CountryRegion1", "China", "United States", "Russia", "Japan" }[i]; untypedPerson.Passport = new[] { "1001", "2010", "9999", "3199992", "00001" }[i]; untypedPeople[i] = untypedPerson; } IEdmCollectionTypeReference entityCollectionType = new EdmCollectionTypeReference( new EdmCollectionType( new EdmEntityTypeReference(personType, isNullable: false))); People = new EdmEntityObjectCollection(entityCollectionType, untypedPeople.ToList()); }
public ITestActionResult PatchCustomerBySSN([FromODataUri] string ssnKey, [FromBody] EdmEntityObject delta) { Assert.Equal("SSN-6-T-006", ssnKey); IList <string> changedPropertyNames = delta.GetChangedPropertyNames().ToList(); Assert.Single(changedPropertyNames); Assert.Equal("Name", String.Join(",", changedPropertyNames)); IEdmEntityObject originalCustomer = null; foreach (var customer in AlternateKeysDataSource.Customers) { object value; if (customer.TryGetPropertyValue("SSN", out value)) { string stringKey = (string)value; if (ssnKey == stringKey) { originalCustomer = customer; } } } if (originalCustomer == null) { return(NotFound()); } object nameValue; delta.TryGetPropertyValue("Name", out nameValue); Assert.NotNull(nameValue); string strName = Assert.IsType <string>(nameValue); dynamic original = originalCustomer; original.Name = strName; return(Ok(originalCustomer)); }
public IActionResult GetNavigation(string key, string navigation) { ODataPath path = Request.ODataFeature().Path; if (path.PathTemplate != "~/entityset/key/navigation") { return(BadRequest("Not the correct navigation property access request!")); } NavigationPropertySegment property = path.Segments.Last() as NavigationPropertySegment; if (property == null) { return(BadRequest("Not the correct navigation property access request!")); } IEdmEntityType entityType = property.NavigationProperty.DeclaringType as IEdmEntityType; EdmEntityObject entity = new EdmEntityObject(entityType); string sourceString = Request.GetDataSource(); DataSourceProvider.Get(sourceString, key, entity); object value = DataSourceProvider.GetProperty(sourceString, navigation, entity); if (value == null) { return(NotFound()); } IEdmEntityObject nav = value as IEdmEntityObject; if (nav == null) { return(NotFound()); } return(Ok(nav)); }
// https://github.com/OData/WebApi/blob/7.0.0/src/Microsoft.AspNet.OData/Results/ResultHelpers.cs // https://github.com/OData/WebApi/blob/eaeed9a2a031b58b73946a91b1c45b52229cc828/src/Microsoft.AspNet.OData.Shared/Results/ResultHelpers.cs // https://github.com/OData/WebApi/blob/eaeed9a2a031b58b73946a91b1c45b52229cc828/src/Microsoft.AspNet.OData.Shared/EdmModelExtensions.cs // https://github.com/OData/WebApi/blob/955ee08511485f9b5ca46a4c9d6736a7e0357e85/src/Microsoft.AspNet.OData.Shared/Formatter/ClrTypeCache.cs https://github.com/OData/WebApi/blob/eaeed9a2a031b58b73946a91b1c45b52229cc828/src/Microsoft.AspNet.OData.Shared/Formatter/EdmLibHelpers.cs public static Uri GenerateODataLink(HttpRequestMessage request, IEdmEntityObject entity, bool isEntityId) { var model = request.GetModel(); var path = request.ODataProperties().Path; var navigationSource = path.NavigationSource; var resourceContext = new ResourceContext( new ODataSerializerContext { NavigationSource = navigationSource, Model = model, Url = request.GetUrlHelper() ?? new UrlHelper(request), MetadataLevel = ODataMetadataLevel.FullMetadata, // Used internally to always calculate the links. Request = request, Path = path }, entity.GetEdmType().AsEntity(), entity ); return(GenerateODataLink(resourceContext, isEntityId)); }
private static void BuildCompanies(IEdmModel model) { IEdmEntityType companyType = model.SchemaElements.OfType <IEdmEntityType>().First(e => e.Name == "Company"); IList <IEdmComplexObject> addresses = BuildAddrsses(model); IEdmEntityObject[] untypedCompanies = new IEdmEntityObject[5]; for (int i = 0; i < 5; i++) { dynamic untypedCompany = new EdmEntityObject(companyType); untypedCompany.ID = i; untypedCompany.Location = addresses[i]; untypedCompanies[i] = untypedCompany; } IEdmCollectionTypeReference entityCollectionType = new EdmCollectionTypeReference( new EdmCollectionType( new EdmEntityTypeReference(companyType, isNullable: false))); Companies = new EdmEntityObjectCollection(entityCollectionType, untypedCompanies.ToList()); }
public string Create(IEdmEntityObject entity) { var edmType = entity.GetEdmType(); var table = (edmType.Definition as EdmEntityType).Name; if (this.PermissionCheck != null && !this.PermissionCheck(MethodType.Create, table)) { throw new UnauthorizedAccessException(); } object rtv = null; string cmdTemplate = "insert into [{0}] ({1}) values ({2}) select SCOPE_IDENTITY() "; List<string> cols = new List<string>(); List<string> pars = new List<string>(); List<SqlParameter> sqlpars = new List<SqlParameter>(); object v = null; foreach (var p in (entity as Delta).GetChangedPropertyNames()) { entity.TryGetPropertyValue(p, out v); cols.Add(string.Format("[{0}]", p)); pars.Add("@" + p); sqlpars.Add(new SqlParameter("@" + p, v)); } using (DbAccess db = new DbAccess(this.ConnectionString)) { rtv = db.ExecuteScalar(string.Format(cmdTemplate, table, string.Join(", ", cols), string.Join(", ", pars)) , (dbpars) => { dbpars.AddRange(sqlpars.ToArray()); }, CommandType.Text); } return rtv.ToString(); }
private static void BuildPeople(IEdmModel model) { IEdmEntityType personType = model.SchemaElements.OfType<IEdmEntityType>().First(e => e.Name == "Person"); IEdmEntityObject[] untypedPeople = new IEdmEntityObject[5]; for (int i = 0; i < 5; i++) { dynamic untypedPerson = new EdmEntityObject(personType); untypedPerson.ID = i; untypedPerson.Country = new[] { "Great Britain", "China", "United States", "Russia", "Japan" }[i]; untypedPerson.Passport = new[] { "1001", "2010", "9999", "3199992", "00001"}[i]; untypedPeople[i] = untypedPerson; } IEdmCollectionTypeReference entityCollectionType = new EdmCollectionTypeReference( new EdmCollectionType( new EdmEntityTypeReference(personType, isNullable: false))); People = new EdmEntityObjectCollection(entityCollectionType, untypedPeople.ToList()); }
public IHttpActionResult Post(IEdmEntityObject customer) { if (!ModelState.IsValid) { return BadRequest("customer is null"); } postedCustomer = customer; object id; customer.TryGetPropertyValue("Id", out id); return Created(Url.CreateODataLink(new EntitySetPathSegment("UntypedCustomer"), new KeyValuePathSegment(id.ToString())), customer); }
public HttpResponseMessage Post(IEdmEntityObject entity) { if (entity == null) return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "entity cannot be empty"); ODataPath path = Request.ODataProperties().Path; IEdmType edmType = path.EdmType; if (edmType.TypeKind != EdmTypeKind.Collection) { throw new Exception("we are serving POST {entityset}"); } string rtv = null; string dsName = (string)Request.Properties[Constants.ODataDataSource]; var ds = DataSourceProvider.GetDataSource(dsName); if (DynamicOData.BeforeExcute != null) { var ri = new RequestInfo(dsName) { Method = MethodType.Create, Target = (edmType as EdmEntityType).Name }; DynamicOData.BeforeExcute(ri); if (!ri.Result) return Request.CreateResponse(ri.StatusCode, ri.Message); } try { rtv = ds.Create(entity); return Request.CreateResponse(HttpStatusCode.Created, rtv); } catch (UnauthorizedAccessException ex) { return Request.CreateErrorResponse(HttpStatusCode.Unauthorized, ex); } catch (Exception err) { return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, err); } }
private bool HasId(IEdmEntityObject product, int key) { object id; return product.TryGetPropertyValue("Id", out id) && (int)id == key; }
private static void BuildCompanies(IEdmModel model) { IEdmEntityType companyType = model.SchemaElements.OfType<IEdmEntityType>().First(e => e.Name == "Company"); IList<IEdmComplexObject> addresses = BuildAddrsses(model); IEdmEntityObject[] untypedCompanies = new IEdmEntityObject[5]; for (int i = 0; i < 5; i++) { dynamic untypedCompany = new EdmEntityObject(companyType); untypedCompany.ID = i; untypedCompany.Location = addresses[i]; untypedCompanies[i] = untypedCompany; } IEdmCollectionTypeReference entityCollectionType = new EdmCollectionTypeReference( new EdmCollectionType( new EdmEntityTypeReference(companyType, isNullable: false))); Companies = new EdmEntityObjectCollection(entityCollectionType, untypedCompanies.ToList()); }
private bool HasId(IEdmEntityObject product, int key) { object id; return(product.TryGetPropertyValue("Id", out id) && (int)id == key); }
public HttpResponseMessage Put(string key, IEdmEntityObject entity) { string dsName = (string)Request.Properties[Constants.ODataDataSource]; var ds = DataSourceProvider.GetDataSource(dsName); if (DynamicOData.BeforeExcute != null) { var ri = new RequestInfo(dsName) { Method = MethodType.Replace, Target = (entity.GetEdmType().Definition as EdmEntityType).Name }; DynamicOData.BeforeExcute(ri); if (!ri.Result) return Request.CreateResponse(ri.StatusCode, ri.Message); } try { var count = ds.Replace(key, entity); return Request.CreateResponse(HttpStatusCode.OK, count); } catch (UnauthorizedAccessException ex) { return Request.CreateErrorResponse(HttpStatusCode.Unauthorized, ex); } catch (Exception err) { return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, err); } }
public int Merge(string key, IEdmEntityObject entity) { string cmdTemplate = "update [{0}] set {1} where [{2}]=@{2} "; var entityType = entity.GetEdmType().Definition as EdmEntityType; if (this.PermissionCheck != null && !this.PermissionCheck(MethodType.Merge, entityType.Name)) { throw new UnauthorizedAccessException(); } var keyDefine = entityType.DeclaredKey.First(); List<string> cols = new List<string>(); List<SqlParameter> sqlpars = new List<SqlParameter>(); object v = null; foreach (var p in (entity as Delta).GetChangedPropertyNames()) { entity.TryGetPropertyValue(p, out v); cols.Add(string.Format("[{0}]=@{0}", p)); sqlpars.Add(new SqlParameter("@" + p, v)); } if (cols.Count == 0) return 0; sqlpars.Add(new SqlParameter("@" + keyDefine.Name, key.ChangeType(keyDefine.Type.PrimitiveKind()))); int rtv; using (DbAccess db = new DbAccess(this.ConnectionString)) { rtv = db.ExecuteNonQuery(string.Format(cmdTemplate, entityType.Name, string.Join(", ", cols), keyDefine.Name) , (dbpars) => { dbpars.AddRange(sqlpars.ToArray()); }, CommandType.Text); } return rtv; }
private object GetPropertyValue(IEdmEntityObject p, string attributeName) { p.TryGetPropertyValue(attributeName, out object value); return(value); }
public int Replace(string key, IEdmEntityObject entity) { string cmdTemplate = "update [{0}] set {1} where {2} "; var entityType = entity.GetEdmType().Definition as EdmEntityType; if (this.PermissionCheck != null && !this.PermissionCheck(MethodType.Replace, entityType.Name)) { throw new UnauthorizedAccessException(); } var keyName = entityType.DeclaredKey.First().Name; List<string> cols = new List<string>(); List<string> pars = new List<string>(); List<SqlParameter> sqlpars = new List<SqlParameter>(); object v = null; foreach (var p in entityType.Properties()) { entity.TryGetPropertyValue(p.Name, out v); cols.Add(string.Format("[{0}]", p.Name)); pars.Add("@" + p.Name); sqlpars.Add(new SqlParameter("@" + p.Name, v == null ? DBNull.Value : v)); } int rtv; using (DbAccess db = new DbAccess(this.ConnectionString)) { rtv = db.ExecuteNonQuery(string.Format(cmdTemplate, entityType.Name, string.Join(", ", cols), string.Join(", ", pars)) , (dbpars) => { dbpars.AddRange(sqlpars.ToArray()); }, CommandType.Text); } return rtv; }
protected object GetPropertyValue(IEdmEntityObject p, string attributeName) { p.TryGetPropertyValue(attributeName, out object value); return(value != null ? value : null); }
public HttpResponseMessage Put(int key, IEdmEntityObject entity) { return(Request.CreateResponse(HttpStatusCode.NoContent)); }
public IEdmEntityObject Post([FromBody] IEdmEntityObject doc) => doc;