First of all, sorry for the probable English mistakes
I created a table in my postgresql database using the entity framework.
In edmx in the creation section I passed as bytea, however in the mapping I used binary (primitive type use is necessary).
<EntityType Name="styleexample">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="example" Type="String" MaxLength="40" />
<Property Name="example1" Type="Binary" />
<Property Name="example2" Type="DateTime" />
</EntityType>
<EntityType Name="styleexample">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="int4" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="example" Type="varchar" MaxLength="40" />
<Property Name="example1" Type="bytea" />
<Property Name="example2" Type="timestamp" />
</EntityType>
The table was created with the correct typing
In the entity I referenced the column as byte []
In the column I inserted the base64 string of a png image, but in the service when I return the value is different from what I inserted
My response is also byte[]
It works. However, it returns the incorrect value. Is there a different way to do this process?
I solved the issue by adding to the service
var example1 = new StreamReader(new MemoryStream(estilo.example1));
var example1Stream = example1 .ReadToEnd();
Related
I am trying to generate the model from an existing OData service through jaysvcutil and am getting:
[...]\node_modules\jaydata-odatajs\lib\odata\odatautils.js:385
throw err;
^
TypeError: Cannot read property 'schemas' of undefined
at Metadata.processMetadata ([...]\node_modules\jaydata-dynamic-metadata\lib\metadata.js:353:35)
at requestData ([...]\node_modules\jaydata-dynamic-metadata\lib\metadataHandler.js:46:42)
at [...]\node_modules\jaydata-odatajs\lib\odata\odatautils.js:382:13
at IncomingMessage.<anonymous> ([...]\node_modules\jaydata-odatajs\lib\odata\net.js:179:21)
at emitNone (events.js:72:20)
at IncomingMessage.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:921:12)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickCallback (node.js:356:17)
I tried to condense the domain model into something really simple, so my current $metadata looks like this:
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2007/05/edm" Namespace="data">
<EntityType Name="Product">
<Key>
<PropertyRef Name="ProductId"/>
</Key>
<Property Name="ProductId" Type="Edm.Int64" Nullable="false"/>
<Property Name="ProductNo" Type="Edm.String" Nullable="true"/>
<Property Name="LifeTime" Type="Edm.Int64" Nullable="false"/>
<Property Name="Capacity" Type="Edm.Int64" Nullable="false"/>
<Property Name="PackingSize" Type="Edm.Int64" Nullable="false"/>
<Property Name="CreationTime" Type="Edm.DateTime" Nullable="false"/>
<Property Name="ModificationTime" Type="Edm.DateTime" Nullable="false"/>
</EntityType>
</Schema>
<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2007/05/edm" Namespace="Namespace">
<EntityContainer Name="DomainData" m:IsDefaultEntityContainer="true">
<EntitySet Name="Product" EntityType="data.Product"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
This is an existing WCF DataService based OData provider using OData V1 and I am not able to change that - so please do not recommend updating the provider to V4.
Any help would be appreciated.
As per feedback from the JayData team:
JayData supports OData v4, as there have been multiple breaking changes in both OData and DataJS since v1.
and also
JayData 1.3.7 supports v2 and v3, but it does not support TypeScript and Angular 2.
I will therefore be looking at alternatives, presumably breezejs.
I've got a problem about usage of json data in smart table object. I'm getting json data from web service and I set that json data any other variable. How can I bind that variable to EntitySet ? In fact I haven't got any json file in my application folders.
Here is the application sample link that I used for my project;
https://sapui5.netweaver.ondemand.com/explored.html#/sample/sap.m.tutorial.walkthrough.27/code
Here is the my metadata.xml codes;
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="UserModel" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityType Name="Users">
<Key>
<PropertyRef Name="TKID"/>
<PropertyRef Name="TKTX"/>
</Key>
<Property Name="TKTX" Type="Edm.String" Nullable="false" MaxLength="40" FixedLength="false" Unicode="true"/>
<Property Name="TKID" Type="Edm.Int16" Nullable="false"/>
</EntityType>
</Schema>
<Schema Namespace="ODataWebV2.Northwind.Model" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityContainer Name="UserModelEntities" m:IsDefaultEntityContainer="true" p6:LazyLoadingEnabled="true"
xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
<EntitySet Name="Users" EntityType="UserModel.Users"/>
<!--How can I bind my json data incoming from webservice ?-->
</EntityContainer>
</Schema>
</edmx:DataServices>
Thanks for your help.
I am using Activiti Explorer version 5.17, I want to send mail by using Mail Task but it not work.
My config:
In engine.properties file (I can not found activiti.cfg.xml file):
engine.email.enabled=true
engine.email.host=myserver.com.vn
engine.email.port=25
engine.email.username=test
engine.email.password=test#123
My Mail Task
<serviceTask id="sid-024BFBEB-EC9D-475E-BE44-6E0996FFB64D" activiti:type="mail">
<extensionElements>
<activiti:field name="from" stringValue="test#myserver.com.vn" />
<activiti:field name="to" expression="test#myserver.com.vn" />
<activiti:field name="subject" expression="Your order has been shipped" />
<activiti:field name="html">
<activiti:expression>
<![CDATA[
<html>
<body>
Hello ,<br/><br/>
As of now, your order has been <b>processed and shipped</b>.<br/><br/>
Kind regards,<br/>
TheCompany.
</body>
</html>
]]>
</activiti:expression>
</activiti:field>
</extensionElements>
</serviceTask>
When i run process, nothing is display in console, and it not work.
Thanks for any help. :)
I tried something but in the version 5.18(I'm not sure if can be applicable on your version), try to configure those thing on activiti-custom-context.xml(placed in activiti-explorer\WEB-INF\classes). Also you can configure your db connection, for example.
First uncomment the beans and then fill your db information in the bean with the id "dataSource".
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/database" />
<property name="username" value="user" />
<property name="password" value="password" />
<property name="defaultAutoCommit" value="false" />
</bean>
To configure the email add some properties to the bean with the id "processEngineConfiguration"
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="true" />
<property name="enableDatabaseEventLogging" value="true" />
<property name="customFormTypes">
<list>
<bean class="org.activiti.explorer.form.UserFormType"/>
<bean class="org.activiti.explorer.form.ProcessDefinitionFormType"/>
<bean class="org.activiti.explorer.form.MonthFormType"/>
</list>
</property>
<property name="mailServerUseTLS" value="true" /><!--This is important if you use Gmail as your hoster -->
<property name="mailServerHost" value="smtp.gmail.com" />
<property name="mailServerPort" value="587" />
<property name="mailServerUsername" value="my#host.com" />
<property name="mailServerPassword" value="hostpassword"/>
</bean>
Is it possbile to configure AutoFixture so that it adheres the entity constraints [from the EDMX file]?
E.g. Consider a snippet from the CSDL section of my EDMX file:
<EntityType Name="RndtAd">
...
<Property Name="AD" Type="Decimal" Precision="12" Scale="0" Nullable="false" />
<Property Name="USERNAME" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
<Property Name="VERSION" Type="Decimal" Precision="12" Scale="4" Nullable="false" />
<Property Name="EFFECTIVE_FROM" Type="DateTime" Precision="3" />
<Property Name="EFFECTIVE_FROM_TZ" Type="DateTime" Precision="7" />
<Property Name="EFFECTIVE_TILL" Type="DateTime" Precision="3" />
<Property Name="EFFECTIVE_TILL_TZ" Type="DateTime" Precision="7" />
<Property Name="IS_TEMPLATE" Type="String" MaxLength="1" FixedLength="true" Unicode="false" />
<Property Name="IS_USER" Type="String" MaxLength="1" FixedLength="true" Unicode="false" />
<Property Name="STRUCT_CREATED" Type="String" MaxLength="1" FixedLength="true" Unicode="false" />
<Property Name="AD_TP" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="PERSON" Type="String" MaxLength="40" FixedLength="false" Unicode="true" />
<Property Name="TITLE" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="FUNCTION_NAME" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="COMPANY" Type="String" MaxLength="40" FixedLength="false" Unicode="true" />
<Property Name="STREET" Type="String" MaxLength="40" FixedLength="false" Unicode="true" />
...
What I would like if fixture.Create<RndtAd>() generated randomly an entity where all the previous constraints are satisfied.
What options do I have? All suggestions are welcome.
EDIT. I'm not bound to AutoFixture. If there is another tool which does the job, I'm ok with that too.
AutoFixture has no built-in support for Entity Framework, but during the last couple of years, several people have fought their own battles to integrate the two.
Here's what a Google search turned up for me:
Autofixture and Moq to test Entity Framework project
AutoFixture.AutoEntityFramework
Creating a domain model without circular references in Entity Framework
Using autofixture in my data integration tests to create proxies
How to mockup Entity Framework 6 With Moq & Autofixture
Perhaps you can find some inspiration by looking some of those resources over.
As-is, AutoFixture can't be customized through .EDMX files.
I am using EF4 to map a DB schema to an object model; I initially generated the EDMX from the database but have been editing the XML directly (trying to leave the SSDL the same while changing the CSDL/MSL to approximate the object model I want). The database contains, among many other things, a couple tables with a (0..)1-to-many constraint via foreign key like so:
go
create table Options (
KitNodeID int primary key foreign key references KitNodes (KitNodeID),
[SKUID] int null foreign key (SKUID) references SKUs (SKUID)
)
go
create table Upgrades (
UpgradeID int identity (1, 1) primary key not null,
[Name] nvarchar(50) not null,
DefaultOptionID int null references Options (KitNodeID)
)
The relevant sections in the EDMX look like this:
[...]
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="DModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
<EntityContainer Name="DModelStoreContainer">
<AssociationSet Name="FK__Upgrades__Defaul__70DDC3D8" Association="DModel.Store.FK__Upgrades__Defaul__70DDC3D8">
<End Role="Options" EntitySet="Options" />
<End Role="Upgrades" EntitySet="Upgrades" />
</AssociationSet>
</EntityContainer>
<EntityType Name="Upgrades">
<Key>
<PropertyRef Name="UpgradeID" />
</Key>
<Property Name="UpgradeID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" />
<Property Name="DefaultOptionID" Type="int" />
</EntityType>
<Association Name="FK__Upgrades__Defaul__70DDC3D8">
<End Role="Options" Type="DModel.Store.Options" Multiplicity="0..1" />
<End Role="Upgrades" Type="DModel.Store.Upgrades" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Options">
<PropertyRef Name="KitNodeID" />
</Principal>
<Dependent Role="Upgrades">
<PropertyRef Name="DefaultOptionID" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema></edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="DModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityContainer Name="DEntities" annotation:LazyLoadingEnabled="true">
<EntitySet Name="Upgrades" EntityType="DModel.Upgrade" />
<AssociationSet Name="Upgrade_DefaultOption" Association="DModel.Upgrade_DefaultOption">
<End Role="Options" EntitySet="Options" />
<End Role="Upgrades" EntitySet="Upgrades" />
</AssociationSet>
</EntityContainer>
<Association Name="Upgrade_DefaultOption">
<End Role="Options" Type="DModel.Option" Multiplicity="0..1" />
<End Role="Upgrades" Type="DModel.Upgrade" Multiplicity="*" />
</Association>
<EntityType Name="Upgrade">
<Key>
<PropertyRef Name="UpgradeID" />
</Key>
<Property Name="UpgradeID" Nullable="false" annotation:StoreGeneratedPattern="Identity" Type="Int32" />
<Property Name="Name" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="false" />
<NavigationProperty Name="DefaultOption" Relationship="DModel.Upgrade_DefaultOption" FromRole="Upgrades" ToRole="Options" />
<NavigationProperty Name="OptInOptions" Relationship="DModel.OptInOptions" FromRole="Upgrades" ToRole="Options" />
</EntityType>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
<EntityContainerMapping StorageEntityContainer="DModelStoreContainer" CdmEntityContainer="DEntities">
<EntitySetMapping Name="Upgrades"><EntityTypeMapping TypeName="DModel.Upgrade"><MappingFragment StoreEntitySet="Upgrades">
<ScalarProperty Name="UpgradeID" ColumnName="UpgradeID" />
<ScalarProperty Name="Name" ColumnName="Name" />
</MappingFragment></EntityTypeMapping></EntitySetMapping>
<AssociationSetMapping Name="Upgrade_DefaultOption" TypeName="DModel.Upgrade_DefaultOption" StoreEntitySet="FK__Upgrades__Defaul__70DDC3D8">
<EndProperty Name="Upgrades">
<ScalarProperty Name="UpgradeID" ColumnName="UpgradeID"/>
</EndProperty>
<EndProperty Name="Options">
<ScalarProperty Name="KitNodeID" ColumnName="DefaultOptionID"/>
</EndProperty>
</AssociationSetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
It will generate code, but when I try to use it I get an "Error 2007: The Table 'FK_Upgrades_Defaul__70DDC3D8' specified as part of this MSL does not exist in MetadataWorkspace." It looks like it can't find the underlying foreign key constraint that the SSDL is supposed to use, but I do see one with that name in the database.
Really, I feel I don't have a very good understanding of how this kind of mapping is supposed to work in general - is a foreign key constraint in the database really treated as an "associationset"? - but this is the closest I can work out. I don't know if anyone could diagnose the problem from the info I've given, but any pointers on where to look? I've tried various things like changing the StoreEntitySet to point to Options, etc. but they just result in different errors.
Try changing how you define your foreign key, see: How do I create a foreign key in SQL Server?
You will probably have to delete and recreate you model.