Linq To SQL : Error "Database node not found" - linq-to-sql

I am attempting to experiment with linq to sql using this site as a guide.
When running a test I keep getting an error parsing the mapping file I created. The error:
System.Xml.Schema.XmlSchemaException : Database node not found. Is the mapping namespace (http://schemas.microsoft.com/linqtosql/mapping/2007) correctly specified?
Here is the mapping file:
<?xml version="1.0" encoding="utf-8"?>
<Database Name="Test" xmlns="http://schemas.microsoft.com/linqtosql/mapping/2007">
<Table Name="dbo.Categories" Member="Category">
<Type Name="Category">
<Column Name="ID" Member="ID" Storage="id" DbType="Char(32) NOT NULL" CanBeNull="false" IsPrimaryKey="true" />
<Column Name="ParentID" Member="ParentID" Storage="parentID" DbType="Char(32)" />
<Column Name="Name" Member="Name" Storage="name" DbType="VarChar(50) NOT NULL" CanBeNull="false" />
</Type>
</Table>
</Database>
Can anyone point me in the right direction?

Figured it out!
the line:
<Table Name="dbo.Categories" Member="Category">
Needed changed to:
<Table Name="dbo.Categories" Member="Categories">
and now its working.

Related

Liquibase CSV loadData fails with quoted string containing a comma

I am trying to load CSV file into SQLserver table using Liquibase change log set.
When saved XLSX file as CSV file, column containing comma saved in double quotes (please see 3rd value below), this is fine as per standards but liquibase is ignoring double quotes and considering comma inside the double-quotes.
13,OV,"Diabetes outpatient self-management training services individual,per 30 minutes",77.82,1,0,1/4/2016,,G0108
Error messgae from command line terminal:
CSV file v2.1/r21/TestData20212021.csv Line 21 has 10 values defined, Header has 9. Numbers MUST be equal (check for unquoted string with embedded commas)
<changeSet author="sprint-developer" id="sprint1-09">
<loadData
file="v2.1/r21/TestData2021.csv"
tableName = "tbl_Votes" encoding="UTF-8" >
<column header="VcenarioID" name="VcenarioID" type="numeric"/>
<column header="venefitCode" name="venefitCode" type="string"/>
<column header="KostDescription" name="KostDescription" type="string"/>
<column header="Kost" name="Kost" type="NUMERIC"/>
<column header="OcKurrences" name="OKcurrences" type="numeric"/>
<column header="KostIsPerIncident" name="KostIsPerIncident" type="boolean"/>
<column header="KostDate" name="KostDate" type="date"/>
<column header="VundleId" name="VundleId" type="NUMERIC"/>
<column header="VillingCode" name="VillingCode" type="string"/>
</loadData>
<rollback>Delete from tbl_Votes where VcenarioID=13 </rollback>
</changeSet>
Try adding quotchar='"' to your changeSet. This should tell liqbuiase to treat everything inside "" as one single value.
Check out loadData docs.
So your changeSet could look like this:
<changeSet author="sprint-developer" id="sprint1-09">
<loadData
file="v2.1/r21/TestData2021.csv"
tableName = "tbl_Votes" encoding="UTF-8" quotchar='"'>
<column header="VcenarioID" name="VcenarioID" type="numeric"/>
<column header="venefitCode" name="venefitCode" type="string"/>
<column header="KostDescription" name="KostDescription" type="string"/>
<column header="Kost" name="Kost" type="NUMERIC"/>
<column header="OcKurrences" name="OKcurrences" type="numeric"/>
<column header="KostIsPerIncident" name="KostIsPerIncident" type="boolean"/>
<column header="KostDate" name="KostDate" type="date"/>
<column header="VundleId" name="VundleId" type="NUMERIC"/>
<column header="VillingCode" name="VillingCode" type="string"/>
</loadData>
<rollback>Delete from tbl_Votes where VcenarioID=13 </rollback>
</changeSet>

HTML template in xml - what kind of architecture is this?

My project has many xml files which are using to build html page & page operations. Here is the sample of grid template.
<Contact singular="Contact" indeal="" nodeal="ContactsPlaybook" tooltip="Document Playbook" library="true" tabHidden="true">
<ListingScreen handle = "PlaybookContacts.ashx" suppressCount="true" showFilters="true">
<IncludeScript src="scripts/jjedsEmaUser.js"/>
<SmartIcon editMode="false" requiredAction="Create" name="new" image="new.png" tooltip="Create" separator="false" href="PlaybookContactDetail.ashx?DealRef=${DealRef}" edit="true" />
<SmartIcon editMode="false" requiredAction="Delete" name="BulkDelete" image="delete.png" tooltip="Delete" separator="true"/>
<SmartIcon editMode="false" requiredAction="Read" actionOn="Contact" name="email" image="mail.png" tooltip="Email Team" href="PlaybookEmailTeam.ashx?DealRef=${DealRef}&Subject=Playbook&Body=${LinkToPage}" edit="true" />
<SmartIcon editMode="false" requiredAction="Read" name="print" image="print.png" tooltip="Print" onclick="javascript:window.print()" />
<!--<SmartIcon editMode="false" requiredAction="Administrate" name="CreateEmaUser" image="add_EMA_user.png" tooltip="Create EMA user" onclick="return emans.jjedsEmaUser.create('${DealRef}', '#ListingForm')" />-->
<Filters>
<Filter label="Functional Team" filter="FunctionalCategoryFilter" field="ContactGroupID" prefix="C" empty="FunctionalCategoryRef_NULL">
<PossibleValues displayProperty="Name" />
</Filter>
<Filter label="Country" filter="CountryFilter" by="name" prefix="AD" field="CountryID" displayProperty="Code" empty="-1">
</Filter>
<Filter label="Business Unit" filter="PickListIntFilter" field="BusinessUnit" prefix="C" empty="-1" onlyifsettingtrue="UseSpecialUserDealAccess">
<PossibleValues category="Deal" subcategory="BusinessUnit" />
</Filter>
</Filters>
<Sorting>
<SortColumn name="FullName" dir="asc"/>
</Sorting>
<Query alias="C" ignoreArchiving="true" ignoreDeal="true">
<Block by="C.ContactGroupID" resolveto="DepartmentName" as="Department" />
<JoinTo table="Address" alias="AD" from="C.AddressID" to="AD.AddressID">
</JoinTo>
<Constraint left="C.IsArchived" int="0" />
</Query>
<Column command="true" title="<input type='checkbox' header='true' onclick='ToggleCheckAll(this);'>" editMode="false" special="IsDelete" macro="Checkbox" onClick="ToggleCheckBox(this);"/>
<Column command="true" requiredAction="Update" title="" field="Blank" dbColumn="C.ContactID" macro="ImageLink" fieldType="Contact" tooltip="Edit" image="edit.png" edit="true" />
<Column title="Full Name" field="FullName" macro="LinkToRef" resolveto="FullContactName" from="C.ContactID" contactAlias="C" linkPage="PlaybookContactDetail.ashx"/>
<Column title="Organization" field="C.Affiliation" macro="Text" />
<Column title="Business Unit" field="C.BusinessUnit" property="BusinessUnit" macro="PickList" category="Deal" subcategory="BusinessUnit" storeInt="true" onlyifsettingtrue="UseSpecialUserDealAccess"/>
<Column title="Role" field="C.Role" macro="Text" />
<Column title="Phone" field="C.Phone" macro="Text" />
<Column title="Email" field="C.Email" macro="MailToRef" />
<DeleteDialog name="ContactDelete" info="If you really want to delete {0} please choose the contact which will be used instead."
title="Confirm delete" type="ContactDeleteDialog" >
</DeleteDialog>
</ListingScreen>
</Contact>
Can anyone tell me what kind of architecture is this and what is the real benefit of using this architecture?
It is used in Single page applications to populate the page using an ajax call from the browser to XML files/JSON files in the server thus avoiding reloading of the entire page.
Look into this example
https://www.w3schools.com/js/tryit.asp?filename=tryjs_ajax_xml2
Here on clicking the button the table gets loaded with the xml data from cd_catalog.xml
https://www.w3schools.com/js/cd_catalog.xml
Its architechture is similar to HTML in the way that both are markup languages.
The data is accessed using the nested structure of the tags.In the cd.catalog example the title column is accessed as catalog->cd->title.

Simple way to reformat a large(ish) XML file?

I'm trying to build a store locator that uses data from an XML file to load the locations.
The current file is set out such as below, once exported from phpmyadmin:
<table name="tblLabs">
<column name="LabID">76</column>
<column name="RegionID">8</column>
<column name="Consultant">Dr M E Herd</column>
<column name="BMS">Mrs C Pickup</column>
<column name="AP">NULL</column>
<column name="AdditionalStaff">NULL</column>
<column name="Department">Pathology Dept</column>
<column name="OrganizationName">Bury General Hospital</column>
<column name="Address">Walmersley Road</column>
<column name="Address1">Bury</column>
<column name="City">Lancs</column>
<column name="PostCode">BL9 6PG</column>
<column name="Tel">0161 1234 1234</column>
<column name="Fax">0161 1234 1234</column>
<column name="EMail">email#email.com</column>
<column name="Comments"></column>
<column name="Public">1</column>
<column name="lat">0.000000</column>
<column name="lng">0.000000</column>
<column name="type"></column>
</table>
For it to work with the javascript file I need it to be formated as below:
<markers>
<marker Consultant="Dr M E Herd"
BMS="Mrs C Pickup"
AP="NULL"
AdditionalStaff="NULL"
Department="Pathology Dept"
name="Bury General Hospital"
address="Walmersley Road"
city="Bury"
state="Lancs"
postal="BL9 6PG"
phone="0161 705 3274"
Fax="0161 705 3418"
email="email#email.com"
Comments=""
lat="53.6145706"
lng="-2.2927511"
type="" />
</markers>
Is there a way I can export from phpmyadmin in the format as above? Or is there another way I can quickly reformat the data as to the way I need it? I also need to add in lat & lng from a batch geocode service I am using.
This can be done rather easily with this XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="no"/>
<xsl:template match="table">
<markers>
<marker>
<xsl:for-each select="column">
<xsl:attribute name="{#name}">
<xsl:value-of select="text()" />
</xsl:attribute>
</xsl:for-each>
</marker>
</markers>
</xsl:template>
</xsl:stylesheet>
You can test it online.
This does not add the latitude and longitude, though - but why aren't you storing this in MySQL?

FuzzyLookup in BIML

I'm trying to do the following in BIML:
I'm at a bit of a loss on how to do this in BIML. Here is what I've tried:
<FuzzyLookup
Name="Fuzzy Lookup"
ConnectionName="WO7"
Exhaustive="true"
AutoPassThroughInputColumns="true"
>
<ExternalReferenceTableInput Table="map.AgencyWO7" />
<Inputs>
<Column SourceColumn="AgencyName" TargetColumn="AgencyName" />
</Inputs>
<Outputs>
<Column SourceColumn="AgencyId" TargetColumn="AgencyIdWO7" />
<Column SourceColumn="AgencyName" TargetColumn="AgencyNameWO7" />
</Outputs>
The result is the following error:
(-1,-1) : Error 5 : The input column for the
Fuzzy Lookup Fuzzy Lookup references external column that cannot be found in the reference table. Verify that the
input mapping references a valid column in the reference table.
Property TargetColumn. EmitSsis. There were errors during compilation.
See compiler output for more information.
I think you are maybe missing a reference to the previous transform which is effectively the joining arrow, had you been using SSDT.
Also the format I use to set passthrough = true is on a per column basis.
<FuzzyLookup Name="Fuzzy Lookup" MatchIndexName="" ConnectionName="WO7">
<InputPath OutputPathName="[Previous Transform Name].Output" />
<ExternalReferenceTableInput Table="map.AgencyWO7" />
<Inputs>
<Column MinSimilarity="85" MatchTypeExact="true" PassThrough="true" SourceColumn="AgencyName" TargetColumn="AgencyName" />
</Inputs>
<Outputs>
<Column SourceColumn="AgencyId" TargetColumn="AgencyIdWO7" />
<Column SourceColumn="AgencyName" TargetColumn="AgencyNameWO7" />
</Outputs>
</FuzzyLookup>
Try the above code, and if all else fails you can design the fuzzy look up in SSDT and then import it into biml using Mist/BimlStudio which is pretty reliable.
https://varigence.com/Mist
Cheers

Linq to SQL Foreign Keys & Collections

I'm a still trying to wrap myself around LINQ to SQL and foreign key relationships.
I have a table called "Parent" and another called "Children". I have a OneToMany relationship, where a Parent can have multiple Children. My DBML looks something like:
<Table Name="" Member="Parents">
<Type Name="Parent">
<Column Member="ParentID" Type="System.String" IsPrimaryKey="true" CanBeNull="false" />
<Column Member="ChildID" Type="System.String" CanBeNull="false" />
<Association Name="Parent_Child" Member="Childs" ThisKey="ParentID" OtherKey="ParentID" Type="Child" />
</Type>
</Table>
<Table Name="" Member="Childs">
<Type Name="Child">
<Column Member="ChildID" Type="System.String" IsPrimaryKey="true" CanBeNull="false" />
<Column Member="ParentID" Type="System.String" CanBeNull="false" />
<Association Name="Parent_Child" Member="Parent" ThisKey="ParentID" OtherKey="ParentID" Type="Parent" IsForeignKey="true" />
</Type>
</Table>
In my code, I would like do to something like:
// parent has already been loaded from the datacontext
parent.Childs = <some collection of children>
db.SubmitChanges();
But when I do that I get the following error:
A member defining the identity of the object cannot be changed.
Consider adding a new object with new identity and deleting the existing one instead.
Can anyone tell me how to properly accomplish this?
this is actually the error of datacontext,i think u have multiple instance of datacontext..
well u can not add any entity in datacontext witch is already fetched through another instance of datacontext...
even u can so it by setting datacontext.objecttrackingenabled to false and then u can add it to another data context then it will work for sure....