« first day (2574 days earlier)      last day (2375 days later) » 
00:00 - 20:0020:00 - 23:00

user7480455
8:30 PM
Hi if there are entity frame work people on I would like to ask you a question
 
user7480455
we are wondering if we are using the ,Equals correctly
 
user7480455
we have some come to follow
 
user7480455
int SomeNum;
SomeEnitiy SomeVar = Somedb.SomeEntity.First(e => e.SomeDataField.Equals(int.TryParse(SomeValueString,out SomeNum )));
 
user7480455
we get this error
 
user7480455
e = {"LINQ to Entities does not recognize the method 'Boolean TryParse(System.String, Int32 ByRef)' method, and this method cannot be translated into a store expression."}
 
8:33 PM
@007 That means you can't use TryParse in a query
 
I'm not even sure how you would translate that into SQL.
 
user7480455
ok so we need to do it outside of that
 
Trying to think about translating a closure into SQL makes my brain go squik
 
Do the parse beforehand and store the result in a variable, then use that in the query
 
user7480455
ok thanks
 
user7480455
8:35 PM
oh so it will not change it into an int
 
user7480455
it only tells you if it can parse it
 
It will return the value in the out variable
 
user7480455
if it can is that when you use convert?
 
In this case SomeNum
 
user7480455
so this can go on a line by itself?
 
user7480455
8:36 PM
nt.TryParse(SomeValueString,out SomeNum
 
user7480455
ok that compiled thanks again
 
Be sure to check the return value to see if the parse failed
 
user7480455
oh with an if statement correct?
 
Probably, but whatever does what you need
 
user7480455
the data is coming from a table an it will always be an int
 
user7480455
8:41 PM
so we will not have to check thankfully
 
Then just use Int32.Parse
 
user7480455
ahh ok
 
But don't come crying to me when it gets a non int value and everything blows up.
 
user7480455
I will read up on that thanks!
 
user7480455
not too many lives will be lost mike... it will be deemed as... acceptable
 
user7480455
8:45 PM
hmmm in the test we are getting non-static field requires a target... I guess... i am now crying
 
8:56 PM
Code pls.
 
user7480455
we were able to fix by removing the .equals and replacing it with == symbols
 
That might not do what you think it does.
 
user7480455
the .equals is not very clear and we may have been using it wrongly
 
user7480455
what do you mean?
 
If an object is not IEquatable == uses the base object comparison, which is object references (i.e., memory locations)
 
user7480455
9:00 PM
oh my you just exceeded everything I know related to modern programming.
 
So if you do someObject == someOtherObject, it really means someRandomMemoryLocation == someOtherRandomMemoryLocation
That being said, you did say these are ints so it should be fine
 
user7480455
I will add these notes to the code for detail review. thanks for your insight
 
user7480455
this would be an issue when attempting re-trivial?
 
user7480455
because it is in random locations?
 
user7480455
I am trying to make sure I understand the area of concern sorry for so many extra additional questions
 
9:05 PM
372
Q: C# difference between == and Equals()

DrahcirI have a condition in a silverlight application that compares 2 strings, for some reason when I use == it returns false while .Equals() returns true. Here is the code: if (((ListBoxItem)lstBaseMenu.SelectedItem).Content.Equals("Energy Attack")) { // Execute code } if (((ListBoxItem)lstBase...

 
user7480455
ahhh ok thanks so much... reading now
 
user7480455
this is pretty complex
 
user7480455
the section about 2. not being equal 2.0 is so odd
 
10:31 PM
yo
im struggling with implementing an sqlite database in my asp.net core web api now
does anyone know a good tutorial? i couldnt find one relevant on the internet
 
00:00 - 20:0020:00 - 23:00

« first day (2574 days earlier)      last day (2375 days later) »