I m getting the error 'Operator '=' incompatible with operand types 'Boolean' and 'String'' when i m trying to filtering the data in the grid with datetime column. i m using jqgrid and fluent nhibernate.
return session.Query<User>().Where(filterExpression).Count();
on the above code i m getting the exception for search according to date time and for bool tpye also.
Does anyone knows what is the issue ?
Thanks
Can you tell us more about filterExpression? What you have so far looks correct, but expression trees are easy to get wrong.
Related
I am doing functionality testing(need to write hive code while referring Scala code) in my project. I am having an issue with my date functions in my code. In Scala we have casted our date data type into string as changed its structure into ‘YYYYMM’, MY value inside my date column is like 201706(YYYYMM), which is not accepted in Hive (read that it accepts only YYYY-MM-DD).
My question is
1) How to change the YYYYMM to YYYY-MM-DD? I have tried casting to date and also UNIX_TIMESTAMP neither of them are working query is getting failed at the end.
2) We are also using filter.to_date (colm1,”YYYYMM”).between(add_months(to_date((colm2),”YYYYMM”),-27), add_months(to_date((colm2),”YYYYMM”),-2))) in our Scala code , How can I change that to HIVE? Unable to get any ideas
Thanks In advance…..
Regards,
M Sontosh Aditya
use
unix_timestamp(DATE_COLUMN, string pattern)
Further understanding please refer DateFuncitos
I am using Linq-to-SQL for accessing SQL Server 2008.
In database I have UNIQUE index on some column.
When I enter duplicated data in that column, LINQ will throw SqlException with an error message. Is there a way to figure out that exception is related to UNIQUE index and not some other SQL error?
Solution I am aware of is to user RegEx to parse exception message, but I would like to know is there more elegant approach?
You could use the SQLException.Number property.
For more details you could iterate the Errors collection each of which have thier own number.
As an aside, in the past I have written my own custom serialiser for SqlException but it appears that in 4.5 ToString() has been overridden so this is not now necessary.
You could check the table having the unique constraint on whether it already has a row with some value in the constrained column:
if (linqDataContext.ConstrainedTable.Any(row => row.ConstrainedColumn == somevalue))
{
//show a message, saying you've already got this value
//and it is not applicable
}
else
{
//accept your changes with smth like this:
linqDataContext.SubmitChanges();
}
Another question, whether this approach is applicable for you, i.e. whether the cost of this query overwhelms the cost of catching an exception and processing it. If the constrained column is indexed, than a simple request on that column must not be that costy.
Im having to edit code in very old classic asp.
Im comparing two values.
I am getting an error saying Type mismatch
This is where it occurs:
if oRsDropDown(id_col) = variable then
the drop down is created form a sql execution
I think the issue may be that the ID column in the db being compared is a big int?
Without knowing the type that oRsDropDown returns, does it work with is?
if oRsDropDown(id_col) is variable then
Say I have an entity MyEntity, and it has a formula-based property fmlaProp. Now say I create a criteria:
s.createCriteria(MyEntity.class)
.setProjection(
Projections.distinct(
Projections.property("fmlaProp")))
.addOrder(Order.asc("fmlaProp"));
in this case I get the following SQL:
SELECT DISTINCT fmlaProp-sql FROM MY_ENTITY_TABLE ORDER BY fmlaProp-sql
Which gives an error on Oracle saying that order-by expression is non-selected. Then I tried the following criteria:
s.createCriteria(MyEntity.class)
.setProjection(
Projections.distinct(
Projections.alias(
Projections.property("fmlaProp"),
"alias1"))
.addOrder(Order.asc("alias1"));
Which generates "order by alias1" which works fine. But it is kind of ugly -- the code must "know" of those formula properties, which violates "write once" principle. Any thoughts or suggestions on that? Thank you in advance.
This is expected behavior from Hibernate. It doesn't have to do with the formula property specifically, but that you want to do ordering with a projected value. From the Hibernate Docs:
An alias can be assigned to a projection so that the projected value can be referred to in restrictions or orderings. Here are two different ways to do this...
As far as alternatives, you could try making the formula property a virtual column (in versions of Oracle 11 and above) or wrapping the table in a view with this column computed. That way, Oracle will know fmlaprop directly, which can be used just like a "normal" column.
How would I sort a DataTable using Linq? I've tried the following but received the error:
InvalidCastException was unahndled by user code. Specified cast is not allowed.
var query = from c in allFiles.AsEnumerable() orderby c.Field<DateTime>(1)
descending select c;
That would suggest that for at least some row, field 1 isn't a DateTime. If it may be null, you might want to try DateTime? instead. Or check that it really is that field in the first place... maybe use a name instead of a number?
The table was dynamically generated and had no actual specified column dataType. When I created the column and specified the dataType the issue was resolved.
I'm not sure why I didn't realize the dataType wasn't defined until after I posted this question.