Tridion Filter : replacement for SetCustomMetaQuery - tridion

What is the replacement for SetCustomMetaQuery in Broker query Mechanism (Tridion 2011)?
I got lots of help through this post posted by me earlier.
for
query.SetCustomMetaQuery("KEY_NAME='Key' AND KEY_STRING_VALUE >= 'Yes'");
I tried
CustomMetaValueCriteria criteria1 = new CustomMetaValueCriteria(new CustomMetaKeyCriteria("Key"), "Yes");
mainCriteria =CriteriaFactory.And(mainCriteria, criteria1);
query.Criteria = mainCriteria;
But I am stuck at below two examples in one of the filter CTs.
query.SetCustomMetaQuery("(((KEY_NAME='EventStartDate' AND
KEY_DATE_VALUE >= '" + lowerDate + "')) or
((KEY_NAME='EventEndDate' AND KEY_DATE_VALUE >= '" + lowerDate + "')))"")
and
query.SetCustomMetaQuery("KEY_NAME = 'Publication_Issue_Date' and
((convert(varchar(10), key_date_value, 101) = convert(varchar(10),
cast('" + sIssueDate + "' as datetime), 101)) or
key_string_value like '%" + dtIssue[%=nNumber%].Year + "-0" + dtIssue[%=nNumber%].Month + "-" + dDay[%=nNumber%] + "%')");
Could any please help me with this?

Thought I'd have a stab at this so could be way off!
How's this for the first example:
CustomMetaValueCriteria criteria1 = new CustomMetaValueCriteria(new CustomMetaKeyCriteria("EventStartDate"), lowerDate, Criteria.GreaterThanOrEqual);
CustomMetaValueCriteria criteria2 = new CustomMetaValueCriteria(new CustomMetaKeyCriteria("EventEndDate"), lowerDate, Criteria.GreaterThanOrEqual);
OrCriteria or = new OrCriteria(criteria1, criteria2);
Assumes that "lowerDate" is a DateTime.
The second one is a bit confusing, it looks like its checking for the existence of "Publication_Issue_Date" and any KEY_DATE_VALE that equals the sIssueDate variable OR that there's a string metadata value in the from of a date. So is that going to be something like?
CustomMetaKeyCriteria criteria1 = new CustomMetaKeyCriteria ("Publication_Issue_Date")
CustomMetaValueCriteria criteria2 = new CustomMetaValueCriteria(sIssueDate);
AndCriteria andCriteria = new AndCriteria(criteria1, criteria2);
string dt = dtIssue[%=nNumber%].Year + "-0" + dtIssue[%=nNumber%].Month + "-" + dDay[%=nNumber%];
CustomMetaValueCriteria criteria3 = new CustomMetaValueCriteria(dt, Criteria.Like)
OrCriteria or = new OrCriteria(andCriteria, criteria3);
Cheers

Please try with:
CustomMetaValueCriteria criteria1 = new CustomMetaValueCriteria(new CustomMetaKeyCriteria("Key"), "Yes", Criteria.GreaterThanOrEqual);
Let me know if this works.

Related

Can someone tell me what is wrong with my code here?

strSql = "Select columnname from tbl where ID = '" & ViewState("v_INID") & "'"
v_ObjDs = v_ObjBREngine.FetchSqlDS(strSql)
name = v_ObjDs.Tables(0).Rows(0).Item(0)
ImageFrame.Attributes.Add("src", "..Drawings/folder/Drawings" + name)
DrawingName = Server.MapPath("~/Drawings/folder/Drawings/" & name)
If Not File.Exists(DrawingName) Then
name = "NoImageFound.jpg"
ImageFrame.Attributes.Add("src", "Images/" + name)
End If
Tell me what is wrong with my code. When I debug this piece of code, then DrawingName has an address. I just want to know that imageFrame syntax is correct or not.
System.IO.Path.GetFileName(DrawingName);
or
System.IO.Path.GetFileName(DrawingName);

While input of date - literal does not match format string

I have this line of code in asp.net through which inserting date into a table
CMPI_EFF_DATE = cc.GetDataSet("SELECT TRM_EFF_STDT as TRM_EFF_STDT FROM TRM_MST WHERE TRM_CODE = " + ddlTrm.SelectedValue + "").Tables[0].Rows[0]["TRM_EFF_STDT"].ToString(),
and i am using oracle database . but while inserting data into it it show's an error
literal does not match format string
Is ddlTrm.SelectedValue string value? if it's true, I thing you should put value in quotes like this
"'" + ddlTrm.SelectedValue+"'"
Full example:
CMPI_EFF_DATE = cc.GetDataSet("SELECT TRM_EFF_STDT as TRM_EFF_STDT FROM TRM_MST WHERE TRM_CODE = '" + ddlTrm.SelectedValue+"'").Tables[0].Rows[0]["TRM_EFF_STDT"].ToString()
I think you are wrong here ddlTrm.SelectedValue + "")
It should be ddlTrm.SelectedValue )
CMPI_EFF_DATE = cc.GetDataSet("SELECT TRM_EFF_STDT as TRM_EFF_STDT FROM TRM_MST WHERE TRM_CODE = " + ddlTrm.SelectedValue).Tables[0].Rows[0]["TRM_EFF_STDT"].ToString(),

How to select a row from a datatable by comparing trimmed data?

filteredrows = Server_Tables[i].Select("Servername='" + searchtext + "'");
The code above compares the data without trimming and selects matched rows.
So how to select rows with trimming?
Try this:
filteredrows = Server_Tables[i].Select("TRIM(Servername) ='" + searchtext.Trim() + "'");
Filter expression used in Datatable.Select supports TRIM function. I've also added Trim() to your entered values since spaces are possible there as well.
Trim searchtext variable;
filteredrows = Server_Tables[i].Select("TRIM(Servername)='%" + searchTerm + "%'");
To trim row values while retrieving with select method you can use;
filteredrows = Server_Tables[i].Select("Servername='%" + searchTerm.Trim() + "%'");
Do you need following;
filteredrows = Server_Tables[i].Select("Trim(Servername)='%" + searchtext.Trim() + "%'");

Group newly made parameter values in linq to sql

I am trying to group newly made key values but i'm not getting it to work.
This is the code
Dim result = From v In dc.tbl_voertuigs
Join tv In dc.tbl_type_voertuigs On tv.pk_type_voertuig Equals v.fk_type_voertuig
Join tbc In dc.tbl_tebehalencertificaats On tbc.pk_tebehalencertificaat Equals v.fk_tebehalencertificaat
Where tbc.naam_certificaat = subquery2
Select New Voertuig With
{
.p_voertuigid = v.fk_type_voertuig,
.p_voertuigomschr = tv.type + " -- " + tv.merk
}
I would like to group on .p_voertuigid. I already tried some options without any result. I hope someone here can help me.
Thanks in advance!
I think i am almost there, but now i'm getting a new exception:
Value of type system.collections.generic.list(of <anonymoustype>) cannot be converted
to system.collections.generic.list(of tbl_voertuig)
This is my new code
Dim result = (From v In dc.tbl_voertuigs
Join tv In dc.tbl_type_voertuigs On tv.pk_type_voertuig Equals v.fk_type_voertuig
Join tbc In dc.tbl_tebehalencertificaats On tbc.pk_tebehalencertificaat Equals v.fk_tebehalencertificaat
Where tbc.naam_certificaat = subquery2
Group By v = New Voertuig With
{
.p_voertuigid = v.fk_type_voertuig,
.p_voertuigomschr = tv.type + " -- " + tv.merk
} Into grp = Group).ToList
Return result
I found the answer, this is the final code and it works
Dim result = From v In dc.tbl_voertuigs
Join tv In dc.tbl_type_voertuigs On tv.pk_type_voertuig Equals v.fk_type_voertuig
Join tbc In dc.tbl_tebehalencertificaats On tbc.pk_tebehalencertificaat Equals v.fk_tebehalencertificaat
Where tbc.naam_certificaat = subquery2
Group By v = New Voertuig With
{
.p_voertuigid = v.fk_type_voertuig,
.p_voertuigomschr = tv.type + " -- " + tv.merk
} Into grp = Group _
Select v
Return result.ToList
I hope this can help someone who has the same problem in the future
Grtz
Yannick

Filter CrystalReport DataSet and binding to the report asp.net

I want to filter dataset taken to bind report.
my code is something like this
Mohan.Reports.DataSet1 ds1 = DataAccess.TNA_APPROVAL_DATA_FOR_PRINTING_STYLEWISE(DateTime.Now.Date, ddlStyle.SelectedValue);
ds1.Tables[0].Select("StyleNO='" + ddlStyle.SelectedValue + "'");
Reports.CrystalReport1 rp = new Mohan.Reports.CrystalReport1();
//DataRow dt =(DataRow) ds1.Tables[0].Select("StyleNO='" + ddlStyle.SelectedValue + "'");
reportTnaApprovalbyUser.SetDataSource(ds1.Tables[0].DefaultView.RowFilter = "StyleNO='" + ddlStyle.SelectedValue + "'");
CrystalReportViewer1.ReportSource = reportTnaApprovalbyUser;
But Data is not displaying on report. I think filteration is not working....
Please Help

Resources