Tick a “Pass Through” check box on the “Available Inputs Column” on a Fuzzy Lookup Transformation using BIML - sql

I am using SQL Server 2008 BIDs / BIML, how do I tick the check box on the “Available Inputs Column” on the Columns tab of the Fuzzy Lookup Transformation Editor, column name is inputFile_id?
I do not won’t to match on this column just pass it through the FLT; simply tick the inputFile_id “Pass Through” checkbox on the columns tab of the Fuzzy Lookup Transformation Editor. Hopefully below a screenshot of the checkbox.
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Connections>
<OleDbConnection Name="SourceData" ConnectionString="Provider=SQLNCLI10;Server=myServer;Initial Catalog=myCat;Integrated Security=SSPI;" DelayValidation="true" />
</Connections>
<Packages>
<Package Name="_step01_CreateIndex" ConstraintMode="Linear">
<Tasks>
<Dataflow Name="My Dataflow Task">
<Transformations>
<OleDbSource Name="list of people to match to reference list" ConnectionName="SourceData">
<DirectInput>select TOP 1000 inputFile_id, forename, surname from dbo.peopleToMatchInputFile</DirectInput>
</OleDbSource>
<!-- Column names must be the same in dbo.peopleToMatchInputFile AND dbo.referenceListOfPeople. -->
<!-- A column from dbo.peopleToMatchInputFile MUST BE mapped to a column in dbo.referenceListOfPeople. -->
<FuzzyLookup Name="FLT - Generate new index"
MatchIndexOptions="GenerateAndPersistNewIndex"
MatchIndexName="dbo.referenceListOfPeopleINDEX"
ConnectionName="SourceData"
Exhaustive="false" >
<ExternalReferenceTableInput Table="dbo.referenceListOfPeople" />
<Inputs>
<Column SourceColumn="forename" TargetColumn="forename" MatchTypeExact ="false" MinSimilarity ="95" />
<Column SourceColumn="surname" TargetColumn="surname" MatchTypeExact="true" />
<Column SourceColumn="inputFile_id" TargetColumn="inputFile_id" PassThrough="true" IsUsed="false"/>
</Inputs>
<Outputs>
<Column SourceColumn="lookup_id" TargetColumn="lookup_id" />
<Column SourceColumn="forename" TargetColumn="OutputAlias_forename" />
<Column SourceColumn="surname" TargetColumn="surname" IsUsed="false" />
<Column SourceColumn="streetName" TargetColumn="streetName" />
<Column SourceColumn="dependantLocality" TargetColumn="dependantLocality" />
<Column SourceColumn="postalCounty" TargetColumn="postalCounty" />
<Column SourceColumn="postTown" TargetColumn="OutputAlias_postTown" />
</Outputs>
</FuzzyLookup>
</Transformations>
</Dataflow>
</Tasks>
</Package>
</Packages>
</Biml>
<## template language="C#" hostspecific="true"#>
<## import namespace="System.Data" #>
<## import namespace="Varigence.Hadron.CoreLowerer.SchemaManagement" #>
<!--
CREATE TABLE [dbo].[peopleToMatchInputFile](
[inputFile_id] [int] IDENTITY(1,1) NOT NULL,
[forename] [varchar](35) NOT NULL,
[surname] [varchar](35) NOT NULL,
[streetName] [varchar](80) NULL,
[batchNo] [int] NULL
)
CREATE TABLE [dbo].[referenceListOfPeople](
[lookup_id] [int] IDENTITY(1,1) NOT NULL,
[forename] [varchar](35) NOT NULL,
[surname] [varchar](35) NOT NULL,
[streetName] [varchar](80) NULL,
[dependantLocality] [varchar](35) NULL,
[postTown] [varchar](35) NULL,
[postalCounty] [varchar](35) NULL
)
-->

Related

entity-find with select-field gives error msg

when run the following code :
<entity-find entity-name="mantle.order.OrderHeaderPartFacilityStatus" list="orderPartList">
<econdition field-name="facilityId" from = "facilityId"/>
<econdition field-name="statusId" operator="in" value="OrderPlaced,"/>
<!-- <select-field field-name="orderId, "/> -->
<!-- <select-field field-name="orderName"/> -->
<!-- <select-field field-name="placedDate"/> -->
<!-- <select-field field-name="grandTotal"/> -->
<!-- <select-field field-name="orderPartSeqId"/> -->
<!-- <select-field field-name="facilityId"/> -->
<!-- <select-field field-name="facilityName"/> -->
<!-- <select-field field-name="partStatusId"/> -->
<!-- <order-by field-name="orderPartSeqId"/> -->
</entity-find>
I got:
"orderPartList": [
{
"enteredByPartyId": null,
"salesChannelEnumId": null,
"recurrenceInfoId": null,
"customerRoleTypeId": "Manager",
"billingAccountId": null,
"placedDate": "2016-01-01T00:00:00+0000",
"telecomContactMechId": null,
"postalContactMechId": null,
"vendorRoleTypeId": null,
"visitId": null,
"lastOrderedDate": null,
"remainingSubTotal": null,
"trackingNumber": null,
"otherPartyOrderId": null,
"statusId": "OrderPlaced",
"giftMessage": null,
"entryDate": null,
"shippingInstructions": null,
"autoCancelDate": null,
"estimatedDeliveryDate": null,
"customerPartyId": "EX_JOHN_DOE",
"validThruDate": null,
"carrierPartyId": null,
"partTotal": 5.1E+2,
"facilityId": "FWorkshopnanneihuan",
"syncStatusId": null,
"estimatedShipDate": null,
"validFromDate": null,
"estimatedPickUpDate": null,
"externalRevision": null,
"orderPartSeqId": "01",
"terminalId": null,
"shipmentMethodEnumId": null,
"shipBeforeDate": null,
"parentOrderId": null,
"isGift": null,
"productStoreId": null,
"orderRevision": 26,
"dontCancelSetDate": null,
"pseudoId": "FWorkshopnanneihuan",
"dontCancelSetUserId": null,
"systemMessageRemoteId": null,
"maySplit": null,
"externalId": null,
"parentPartSeqId": null,
"facilityName": "\u5357\u5185\u73af\u8f66\u95f4",
"orderId": "FOJohndoePassat",
"vendorPartyId": null,
"shipAfterDate": null,
"currencyUomId": null,
"orderName": "John_doe order 1",
"grandTotal": 5.1E+2,
"partStatusId": "OrderOpen",
"partName": "\u7b2c\u4e00\u90e8\u5206 John doe",
"statusDescription": "Placed"
}
],
But when I uncommented the select-field tag, as the following:
<entity-find entity-name="mantle.order.OrderHeaderPartFacilityStatus" list="orderPartList">
<econdition field-name="facilityId" from = "facilityId"/>
<econdition field-name="statusId" operator="in" value="OrderPlaced,"/>
<select-field field-name="orderId, "/>
<!-- <select-field field-name="orderName"/> -->
<!-- <select-field field-name="placedDate"/> -->
<!-- <select-field field-name="grandTotal"/> -->
<!-- <select-field field-name="orderPartSeqId"/> -->
<!-- <select-field field-name="facilityId"/> -->
<!-- <select-field field-name="facilityName"/> -->
<!-- <select-field field-name="partStatusId"/> -->
<!-- <order-by field-name="orderPartSeqId"/> -->
</entity-find>
I then got the following error msg, which might suggest that the select sql not working:
{"errorCode":500,"errors":"java.lang.IllegalArgumentException: Maps with null keys can't be converted to JSON"}
Something wrong?
I am runing MoquiDemo-2.0.0 with customized data.
It might be a bug or something? Someone has clue?
The field-name "orderId, " is not valid. The comma is used to separate multiple field names so it turns that into a list of "orderId" and "", and an empty string is not a valid field name.
Similarly in your econdition on statusId the #value attribute has a comma at the end. If you are trying to include records with a null statusId use the econdition.#or-null attribute. For a more efficient query if that isn't what you are looking for, get rid of the comma and use the equals operator (which is the default so you don't need the operator attribute).
In general this code is sloppy. Moqui tries to be tolerant of funny things and do its best, but invalid field names and such are still invalid and you'll get errors. You may have more errors or warnings in the server side log as well, that is usually the first place to look if something isn't working right.

SQL Server XML Date Import

Having trouble importing an xml date feild into sql server, the other feilds are fine. I have tried numerous way's but it always returns as null. Any help please
2014-02-18T12:15:21.357 is the issue
The XML is
<?xml version="1.0" encoding="utf-8"?>
<MISRoot xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/IGUK.Evolution.FieldToolLite.Lib.MIS">
<Claims>
<Claim>
<Amalgamation>
<ChannelSolutions />
<Name i:nil="true" />
</Amalgamation>
<Appointments>
<Appointment>
<Access />
<AccessGranted>true</AccessGranted>
<AppointmentId>320</AppointmentId>
<EnterTime>2014-02-18T12:15:21.357</EnterTime>
<LeaveTime i:nil="true" />
<Name i:nil="true" />
</Appointment>
</Appointments>
<CustomProducts />
<Id>1220</Id>
<Payments />
<Tasks />
</Claim>
</Claims>
</MISRoot>
THE SQL is
CREATE TABLE [dbo].[xmlImportAppointments](
[ClaimId] [int] not null,
[AppointmentAUTO] [int] not NULL,
[AppointmentId] [int] not NULL,
[EnterTime] [datetime] NULL,
[LeaveTime] [datetime] NULL,
[AccessGranted] [nchar](20) NULL,
) ON [PRIMARY]
GO
WITH XMLNAMESPACES(DEFAULT 'http://schemas.datacontract.org/2004/07/IGUK.Evolution.FieldToolLite.Lib.MIS')
INSERT INTO xmlImportAppointments
(ClaimId, AppointmentAUTO, AppointmentId, EnterTime, LeaveTime, AccessGranted)
SELECT
ClaimId = xmldata.value('(Claim/Id)[1]', 'int'),
AppointmentAUTO = xmldata.value('(Claim/Appointments/Appointment/AppointmentId)[1]', 'int'),
AppointmentId = xmldata.value('(Claim/Appointments/Appointment/AppointmentId)[1]', 'int'),
EnterTime = xmldata.value('(Claims/Appointment/Appointments/EnterTime)[1]', 'datetime'),
LeaveTime = xmldata.value('(Claims/Appointment/Appointments/EnterTime)[1]', 'datetime'),
AccessGranted = xmldata.value('(Claim/Appointments/Appointment/AccessGranted)[1]', 'NCHAR(20)')
FROM
(SELECT CAST(x AS XML)
FROM OPENROWSET(BULK '\\XMLTest\increment.xml',
SINGLE_BLOB) AS T(x)) AS T(x)
CROSS APPLY
x.nodes('/MISRoot/Claims') AS X(xmldata);
SELECT * FROM xmlImportAppointments
You had a problem with your XQuery I had copied your File into a XML variable and was able to retrieve using the following query.
DECLARE #MyXMLVariable XML =
'<?xml version="1.0" encoding="utf-8"?>
<MISRoot xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/IGUK.Evolution.FieldToolLite.Lib.MIS">
<Claims>
<Claim>
<Amalgamation>
<ChannelSolutions />
<Name i:nil="true" />
</Amalgamation>
<Appointments>
<Appointment>
<Access />
<AccessGranted>true</AccessGranted>
<AppointmentId>320</AppointmentId>
<EnterTime>2014-02-18T12:15:21.357</EnterTime>
<LeaveTime i:nil="true" />
<Name i:nil="true" />
</Appointment>
</Appointments>
<CustomProducts />
<Id>1220</Id>
<Payments />
<Tasks />
</Claim>
</Claims>
</MISRoot>';
WITH XMLNAMESPACES(DEFAULT 'http://schemas.datacontract.org/2004/07/IGUK.Evolution.FieldToolLite.Lib.MIS')
SELECT #MyXMLVariable.value('(MISRoot/Claims/Claim/Appointments/Appointment/EnterTime)[1]','DATETIME')
You did not specify the full correct path to EnterTime
'(MISRoot/Claims/Claim/Appointments/Appointment/EnterTime)[1]' --Correct
'(Claims/Appointment/Appointments/EnterTime)[1]' --Yours
Appointment is child of Appointments not the other way around and Claim is a child of Claims best way to do this is to look at Open tags and closed tags

NHibernate one-way association with XRef table

I'm stuck trying to get the mapping I want to persist correctly. For my example, I have an ItemY class which can have 0,1,* Assets. However, an Asset can belong to an ItemY or an ItemZ object. I'm trying to use a cross-reference table to store this.
Schema
TABLE [dbo].[ItemY](
[ItemYID] [int] IDENTITY(1,1) NOT NULL,
--more columns here
TABLE [dbo].[Asset](
[AssetID] [uniqueidentifier] NOT NULL,
[AssetTypeID] [int] NOT NULL,
[DisplayOrder] [int] NOT NULL,
[Location] [varchar](255) NOT NULL,
TABLE [dbo].[ItemYAsset](
[ItemYID] [int] NOT NULL,
[AssetID] [uniqueidentifier] NOT NULL,
Mappings:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MyAssembly" namespace="My.Namespace">
<class name="ItemY" table="ItemY">
<id name="ItemYId" column="ItemYID">
<generator class="identity" />
</id>
<bag name="Images" table="ItemYAsset" inverse="true" cascade="all-delete-orphan">
<key column="ItemYID" not-null="true" />
<many-to-many class="Asset" column="AssetID" unique="true" />
</bag>
<!--more mapping here-->
</class>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MyAssembly" namespace="My.Namespace">
<class name="Asset" table="Asset">
<id name="AssetId" column="AssetID">
<generator class="guid.comb" />
</id>
<property name="DisplayOrder"></property>
<property name="Location"></property>
</class>
</hibernate-mapping>
I don't want to expose an ItemY property on Asset, since an Asset doesn't always belong to an ItemY. My ItemY class persists fine, and also persists the Asset class, but there is nothing added to the association table (ItemYAsset). Any idea what I'm doing wrong?
inverse="true" means the "other side" is responsible for persisting the relationship.
Since you have no "other side" (the relationship is unidirectional), remove that attribute.

Insert to parent and child tables

Hi
I have parent and child table like below
<?xml version="1.0" encoding="utf-8"?>
------- parent --------------
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="HibernateSample.StudMarks,HibernateSample" table="StudMarks" lazy="false">
<id name="Sno" column="SNO" type="int">
<generator class="assigned"/>
</id>
<many-to-one name="Student" column="ID" not-null="true"/>
<property name="Marks" column="Marks" type="int" not-null="true" />
<property name="Rank" column="Rank" type="int" not-null="true" />
</class>
</hibernate-mapping>
------- child --------------
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="HibernateSample.Student,HibernateSample" table="Student" lazy="false">
<id name="Id" column="ID" type="int">
<generator class="native" />
</id>
<property name="Name" column="Name" type="string" not-null="true" />
<property name="Standard" column="Standard" type="string" not-null="true" />
<bag name="StudMarks" cascade="all" lazy="false">
<key column="ID" not-null="true"/>
<one-to-many class="HibernateSample.StudMarks,HibernateSample" />
</bag>
</class>
</hibernate-mapping>
and in .cs file i have like written code like below to insert into parent and child.
StudMarks sm = new StudMarks();
Student st = new Student();
List<StudMarks> sms = new List<StudMarks>();
st.Id = 9;
st.Name = "stud 999";
st.Standard = "99";
sm.Sno = 9;
sm.Marks = 99;
sm.Rank = 9;
sm.Student = st; ------ **Line 1**
st.StudMarks = sms; ------ **Line 2**
session.Save(sm);
session.Flush();
If i commENT "Line 1" in above code only child is inserting. If i comment "Line 2" foreign key constraint error is throwing.
Tables:
CREATE TABLE [dbo].[Student](
[ID] [int] IDENTITY(1,1) NOT NULL, -- PRIMARY KEY
[Name] [varchar](50) NOT NULL,
[Standard] [varchar](50) NOT NULL,
CREATE TABLE [dbo].[StudMarks](
[SNO] [int] NOT NULL, -- PRIMARY KEY
[ID] [int] NOT NULL, -- FOREIGN KEY
[Marks] [int] NOT NULL,
[Rank] [int] NOT NULL,)
Please let me know how to insert in parent and child at a time in single save operation.
You have a cascade relation from Student->StudentMarks. So you should be saving st...
session.Save(st);
You should also specify inverse="true" on the bag so you don't get double updates of the foreign key and a cascade="all-delete-orphan" is probably appropriate here as you want all StudentMarks to be deleted when the Student is deleted.
I believe you need to specify inverse="true" on the Student mapping of the StudMarks collection property, indicating that the StudMark mapping is the owner of the relationship.

StoredProcedure returning multiple resultset Sql To Linq using designer

I want to get multiple resultsets from a storedProc using sql to linq. I was not able to generate it from designer so I wrote below code in designer.cs file. But whenever I add something to designer, it refreshes the designer with the markup in .dbml file and hence it removes the below code every time I add something. I have to copy it every time. If I can get corresponding dbml markup for this, it would be great.
[Function(Name = "dbo.GetAllModulesAndOptions")]
[ResultType(typeof(Module))]
[ResultType(typeof(ModuleOption))]
public IMultipleResults GetAllModules()
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())));
return ((IMultipleResults)(result.ReturnValue));
}
I've already defined Module and ModuleOption as tables.
Now when I add below markup in .dbml file it complains
DBML1114: The Name attribute 'Module' of the Type element is already used by another type.
<Function Name="dbo.GetAllModulesAndOptions" Method="GetAllModules">
<ElementType Name="Module">
<Column Name="ModuleId" Type="System.Int64" DbType="BigInt NOT NULL" CanBeNull="false" />
<Column Name="ModuleName" Type="System.String" DbType="VarChar(50)" CanBeNull="true" />
<Column Name="Description" Type="System.String" DbType="VarChar(255)" CanBeNull="true" />
<Column Name="SalesDesc" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" />
<Column Name="ParentModuleId" Type="System.Int32" DbType="Int" CanBeNull="true" />
</ElementType>
<ElementType Name="ModuleOption">
<Column Name="ModuleOptionId" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
<Column Name="ModuleOptionName" Type="System.String" DbType="VarChar(50)" CanBeNull="true" />
<Column Name="ModuleOptionDesc" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" />
<Column Name="DefaultPrice" Type="System.Decimal" DbType="Money" CanBeNull="true" />
<Column Name="ModuleId" Type="System.Int64" DbType="BigInt" CanBeNull="true" />
<Column Name="InUse" Type="System.Int32" DbType="Int" CanBeNull="true" />
</ElementType>
</Function>
I'm using Visual Studio 2008 SP1
Add the method to the partial class for the data context.
You achieve this by adding a file with the same name as the data context alongside the dbml file, and use the class declaration:
public partial class YourDataContext
{
[Function(Name = "dbo.GetAllModulesAndOptions")]
[ResultType(typeof(Module))]
[ResultType(typeof(ModuleOption))]
public IMultipleResults GetAllModules()
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo (MethodInfo.GetCurrentMethod())));
return ((IMultipleResults)(result.ReturnValue));
}
}
I'm replying my own answer.
One cannot use the already defined type for result set of stored procedure. So I had to change the name of ElementType to ModuleResult and ModuleOptionResult.
<Function Name="dbo.GetAllModulesAndOptions" Method="GetAllModules">
<ElementType Name="ModuleResult">
<Column Name="ModuleId" Type="System.Int64" DbType="BigInt NOT NULL" CanBeNull="false" />
<Column Name="ModuleName" Type="System.String" DbType="VarChar(50)" CanBeNull="true" />
<Column Name="Description" Type="System.String" DbType="VarChar(255)" CanBeNull="true" />
<Column Name="SalesDesc" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" />
<Column Name="ParentModuleId" Type="System.Int32" DbType="Int" CanBeNull="true" />
</ElementType>
<ElementType Name="ModuleOptionResult">
<Column Name="ModuleOptionId" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
<Column Name="ModuleOptionName" Type="System.String" DbType="VarChar(50)" CanBeNull="true" />
<Column Name="ModuleOptionDesc" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" />
<Column Name="DefaultPrice" Type="System.Decimal" DbType="Money" CanBeNull="true" />
<Column Name="ModuleId" Type="System.Int64" DbType="BigInt" CanBeNull="true" />
<Column Name="InUse" Type="System.Int32" DbType="Int" CanBeNull="true" />
</ElementType>
</Function>
Here are the steps which I took to solve the above problem.
Delete the .designer.cs file
Add above markup to the .dbml file
Exclude .dbml and .dbml.layout file
Include .dbml and .dbml.layout file (this will generate .designer.cs file again but will not include it in the project).
Include .designer file in project.
Get the list of Module type and ModuleOption type as below.
var modules = from row in results.GetResult<ModuleResult>().ToList()
select new Module
{
ModuleId = row.ModuleId,
ModuleName = row.ModuleName,
Description = row.Description,
SalesDesc = row.SalesDesc,
ParentModuleId = row.ParentModuleId
};
var moduleOptions = from row in results.GetResult<ModuleOptionResult>().ToList()
select new ModuleOption
{
ModuleOptionId = row.ModuleOptionId,
ModuleOptionName = row.ModuleOptionName,
ModuleOptionDesc = row.ModuleOptionDesc,
DefaultPrice = row.DefaultPrice,
ModuleId = row.ModuleId,
InUse = row.InUse
};
UPDATE
Still a better way.
Right click the dbml file in solution explorer and select open with. Choose XML Editor and when you save the file within visual studio it automatically generates the designer.cs file.