How to handle dynamic tables in Entity Framework - asp.net-mvc-3

we have requirement like below :
For each customer will upload different files having different columns, column names are different from one client to another client and change in the number columns also.
For that one we will stored all the details in one table like
column1,column2,column3 ...........columnN
And will store column mapping some other table
First name=column1
Second Name=Column2
like this, up to this is ok ,but if we are using entity framework how stronly types will work in this case.
In the front end will show the combox box which will display all the client and we will show the data in the grid
Here is important thing is we have to show the End user column name instead our column name like column1,column2
Out put sholud be like below
Combox box ---- Client name
Grid
First name Second Name
---------------------------------
Harish Kumar

EF is not good choice for this type of application. It will map exactly what you have in database - one big entity with Column1, Column2, etc. properties and one entity with properties like ColumnName, PropertyName. That is all because EF doesn't support advanced data driven mapping.
Your UI / logic will need some logic to correctly interpret these data and moreover it will also have to correctly transform user input and actions back to EF understandable form.
Imho using EF for this is overhead, use ADO.NET directly. Also check SharePoint because it has this already implemented.

Related

Loading records into Dynamics 365 through ADF

I'm using the Dynamics connector in Azure Data Factory.
TLDR
Does this connector support loading child records which need a parent record key passed in? For example if I want to create a contact and attach it to a parent account, I upsert a record with a null contactid, a valid parentcustomerid GUID and set parentcustomeridtype to 1 (or 2) but I get an error.
Long Story
I'm successfully connecting to Dynamics 365 and extracting data (for example, the lead table) into a SQL Server table
To test that I can transfer data the other way, I am simply loading the data back from the lead table into the lead entity in Dynamics.
I'm getting this error:
Failure happened on 'Sink' side. ErrorCode=DynamicsMissingTargetForMultiTargetLookupField,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=,Source=,''Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Cannot find the target column for multi-target lookup field: 'ownerid'.
As a test I removed ownerid from the list of source columns it loads OK.
This is obviously a foreign key value.
It raises two questions for me:
Specifically with regards to the error message: If I knew which lookup it needed to use, how can I specify which lookup table it should validate against? There's no settings in the ADF connector to allow me to do this.
This is obviously a foreign key value. If I only had the name (or business key) for this row, how can I easily lookup the foreign key value?
How is this normally done through other API's, i.e. the web API?
Is there an XRMToolbox addin that would help clarify?
I've also read some posts that imply that you can send pre-connected data in an XML document so perhaps that would help also.
EDIT 1
I realised that the lead.ownertypeid field in my source dataset is NULL (that's what was exported). It's also NULL if I browse it in various Xrmtoolbox tools. I tried hard coding it to systemuser (which is what it actually is in the owner table against the actual owner record) but I still get the same error.
I also notice there's a record with the same PK value in systemuser table
So the same record is in two tables, but how do I tell the dynamics connector which one to use? and why does it even care?
EDIT 2
I was getting a similar message for msauto_testdrive for customerid.
I excluded all records with customerid=null, and got the same error.
EDIT 2
This link appears to indicate that I need to set customeridtype to 1 (Account) or 2 (Contact). I did so, but still got the same error.
Also I believe I have the same issue as this guy.
Maybe the ADF connector suffers from the same problem.
At the time of writing, #Arun Vinoth was 100% correct. However shortly afterwards there was a documentation update (in response to a GitHub I raised) that explained how to do it.
I'll document how I did it here.
To populate a contact with against a parent account, you need the parent accounts GUID. Then you prepare a dataset like this:
SELECT
-- a NULL contactid means this is a new record
CAST(NULL as uniqueidentifier) as contactid,
-- the GUID of the parent account
CAST('A7070AE2-D7A6-EA11-A812-000D3A79983B' as uniqueidentifier) parentcustomerid,
-- customer id is an account
'account' [parentcustomerid#EntityReference],
'Joe' as firstname,
'Bloggs' lastname,
Now you can apply the normal automapping approach in ADF.
Now you can select from this dataset and load into contact. You can apply the usual automapping approach, this is: create datasets without schemas. Perform a copy activity without mapping columns
This is the ADF limitation with respect to CDS polymorphic lookups like Customer and Owner. Upvote this ADF idea
Workaround is to use two temporary source lookup fields (owner team and user in case of owner, account and contact in case of customer) and with parallel branch in a MS Flow to solve this issue. Read more, also you can download the Flow sample to use.
First, create two temporary lookup fields on the entity that you wish to import Customer lookup data into it, to both the Account and Contact entities respectively
Within your ADF pipeline flow, you will then need to map the GUID values for your Account and Contact fields to the respective lookup fields created above. The simplest way of doing this is to have two separate columns within your source dataset – one containing Account GUID’s to map and the other, Contact.
Then, finally, you can put together a Microsoft Flow that then performs the appropriate mapping from the temporary fields to the Customer lookup field. First, define the trigger point for when your affected Entity record is created (in this case, Contact) and add on some parallel branches to check for values in either of these two temporary lookup fields
Then, if either of these conditions is hit, set up an Update record task to perform a single field update, as indicated below if the ADF Account Lookup field has data within it

Odata service for two tables and how to make a master table using both tables in UI5

I want to create an OData service to fetch details from two tables of SAP and fit it using Master detail template in UI5. The first table contains only the product Id and description , while the second table contains the Product Id and product details like manufacturer address,cost , exp date etc
Currently two RFC are created writing the SELECT query on the tables to generate OData service from RFC. Shall i create One Entity set and use both RFC from Read and Query each at Map to Data Source ? or create two entity sets to map one RFC for each Entity set ?
How should be the Odata service query look to develop a master detail application in ui5 fetching data from two tables ? As well as how will make a local master table in UI5 using both table which are fetched.
Well, it depends :)
It looks like you have a 1:1 association between the product header and the details.
So you could model header and details as separate entities and define a 1:1 association between them or you could simplify you model and merge both header and detail attributes into one entity. With the information i have, i would prefer the single entity. You can use ODatas $select parameter to request only specific properties. Your DPC implementation could make use of $select and call only the header RFC if only header fields are requested.
I'm not shure if the master detail template can be used with 1:1 associations. Normally they are used with 1:n as the detail page displays a list of detail items. But you can of course leave the details unbounded in the wizard and bind additional fields later in the object header of the detail page.

What is level of normalization HR Oracle Sample Database?

https://docs.oracle.com/cd/E11882_01/server.112/e40540/tablecls.htm#CNCPT88804
Is it third normal form or maybe fourth normal form ? I know that mostly database have only third normal form.
Based on the LOCATION having a STATE_REGION column in it, as well as a COUNTRY_ID, I'd say that it fails the test for second normal form because the same STATE_COUNTRY could be associated with multiple countries through an error in updating the table.

Entity Framework, odata syntax

As indicated in the Entity Framework image below, I have 3 tables, tblModel, tblModelFetish and tblFetish. A record in tblModel can have multiple records in the tblModelFetish table linked by the modelid column. The tblModelFetish table links to the tblFetish table via the fetishID column to get the fetish description stored in the fetish column. This Entity Model was generated with VS 2010 from an existing database including foreign keys.
a Entity Data Model http://spreadthenudes.com/efmodel.jpg
Using the odata syntax, I'm able to access all models (http://localhost:51157/WcfDataService.svc/tblModels) or a specific model (http://localhost:51157/WcfDataService.svc/tblModels(11)) successfully. I'm having trouble accessing the related tables data via odata, I've tried many permutations including expand etc.
What I want is a result set of all the columns in the tblModel and the related tblFetish records including the fetish column from the tblFetish table. In other words, Mary (a modelname in tableModel) has 3 fetishes (3 records in tblModelFetish) named beach, travel and coffee (stored in tblFetish, fetish column).
What is the odata syntax to acquire this?
thanks for reading! Bob
Try either:
http://localhost:51157/WcfDataService.svc/tblModels(11)?$expand=tblModelFetishes/tblFetish
or
http://localhost:51157/WcfDataService.svc/tblModels?$filter=id eq 11&$expand=tblModelFetishes/tblFetish
Just to make it clear you will not get one huge result set with all columns but the entity graph consisted of your entities.

LINQ-to-Entities, Ambiguous Column Name with association between two views with the same column name

I am just getting into Entity Framework for the first time beyond simple examples.
I am using the model-first approach and am querying the data source with LINQ-to-Entities.
I have created an entity model that I am exposing as an OData service against a database where I do not control the schema. In my model, I have two entities that are based off of two views in this database. I've created an association between the two entities. Both views have a column with the same name.
I am getting the error:
Ambiguous column name 'columnname'. Could not use view or function 'viewname' because of binding errors.
If I was writing the SQL statement myself, I'd qualify one of the column names with an alias to prevent this issue. EF apparently isn't doing that. How do I fix this, short of changing the view? (which I cannot do) I think this does have something to do with these entities being mapped to views, instead of being mapped to actual tables.
Assuming you can change the model have you tried going into the model and just changing one of the column names? I can still see how it might be problematic if the two views are pulling back the same column from the same table. I can tell that when working directly with a model mapped to tables, having identically named columns is not a problem. Even having multiple associations to the same table is handled correctly, the Navigation Properties are automatically given unique names. Depending on which version of EF you used you should be able to dig into the cs file either under the model or under the t4 template file and see what's going on. Then you can always create a partial class to bend it to your will.

Resources