|
namespace System.Collections.Generic
{
[Serializable]
public struct KeyValuePair<tkey, tvalue="">
{
public KeyValuePair(TKey key, TValue value);
public TKey Key { get; }
public TValue Value { get; }
public override string ToString();
}
}
and the dict? dont know every strand of this but i think all dict(dictionaries have been moved to a class. thats my task
|
|
|
|
|
I'm not sure if I follow but if you operate on native objects then the following code should be just fine
System.Collections.Generic.Dictionary<int, string> dict = new Dictionary<int, string>();
dict.Add(1, "A");
dict.Add(2, "B");
foreach (System.Collections.Generic.KeyValuePair<int, string> item in dict) {
System.Diagnostics.Debug.WriteLine(string.Format("Key: {0}, value {1}", item.Key, item.Value));
}
Then again if you have created your own classes, then you should post all the relevant code, meaning definitions and usage in order to see the whole situation.
|
|
|
|
|
okay thanks that worked ur sooo good then last question is it okay?
error: 'dict' is a variable but is used like a mehtod.
error goes here ==> dict(paymentType + "CardPreAuthorizationNumber") = AuthCode;
|
|
|
|
|
Sphinxniuie wrote: error: 'dict' is a variable but is used like a mehtod.
error goes here ==> dict(paymentType + "CardPreAuthorizationNumber") = AuthCode;
Again this depends on the definition of the dict but if it is a generic dictionary, then use brackets [] to define the index instead of parenthesis () which are used to separate parameters for a method. Note that dictionary needs two values, the key as an index and the value as explained in Dictionary<TKey, TValue> Class[^]
|
|
|
|
|
ahh i see thanks again mika its a grEEEEAAAAAAt help for me
|
|
|
|
|
but thanks anyway u saved me from that
|
|
|
|
|
hi im using vs2015 so i tried getting WIX for creating installers , the problem is that when i try 2 install WIX v3.10 (latest) i get an error but WIX 3.9 installed perfectly but somehow its not being recognized in VS
|
|
|
|
|
jamesmc1535 wrote: its not being recognized in VS
Is WIX supposed to be integrated with Visual Studio? I thought it was a standalone package.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
it is a standalone but it integrates with vs /
|
|
|
|
|
I'm posting this here because I believe this to be a threading issue, not a DB issue. FYI, I'm using SQLite with dotConnect and EF.
I'm calling a DAL function from two different places on start of my app. Basically there are two lists both being populated from a DAL call. Both places use Background workers to make the same call:
private void loadWorker_DoWork(object sender, DoWorkEventArgs e)
{
var sensors = AppCore.AppDAL.GetSensors();
e.Result = sensors;
}
Then in the DAL I have a call to get the sensors:
public List<SensorEntity> GetSensors()
{
lock (lockObj)
{
var query = getSensorQuery();
var results = query.OrderBy(x => x.SensorName).ToList();
<pre>
results.ForEach(x => x.Category = GetSensorCategory(x.SensorTypeID));
return results;
}
}
private IQueryable<sensorentity> getSensorQuery()
{
var results = (from s in dataContext.Sensors
select new SensorEntity
{
ID = s.ID,
SensorTypeID = s.SensorTypeID,
SensorName = s.Name,
Description = s.Description,
Address = s.SourceAddress.Value,
LastActivityDT = s.LastUpdate
});
return results;
}
Then for each sensor I get it's Category
public SensorCategoryEntity GetSensorCategory(long ID)
{
var query = getSensorCategoryQuery();
var results = query.Where(x => x.ID == ID).FirstOrDefault();
return results;
}
private IQueryable<SensorCategoryEntity> getSensorCategoryQuery()
{
var query = (from sc in dataContext.SensorTypes
select new SensorCategoryEntity
{
ID = sc.ID,
Name = sc.Name
});
return query;
}
At the point indicated I get
"Object cannot be cast from DBNull to other types."
If I put in a Thread.Sleep, like below, then it works fine. if I block out the second call, it works fine.
private void loadWorker_DoWork(object sender, DoWorkEventArgs e)
{
Thread.Sleep(500);
var sensors = Falcon6Core.Falcon6DAL.GetSensors();
e.Result = sensors;
}
I don't really understand what's going on here. I'm not inserting data... it's just a simple query.. Why would there be any kind of threading problem here?
If it's not broken, fix it until it is
|
|
|
|
|
|
Not really.
Right at the top is says
"Serialized. In serialized mode, SQLite can be safely used by multiple threads with no restriction"
and
"The default mode is serialized."
I haven't changed the threading mode, so it should be default.
If it's not broken, fix it until it is
|
|
|
|
|
dbContext is not thread safe.
Based on the few code fragments you've posted, it looks like you're sharing dbContext between your threads. Assuming your "lock" is even a solution, I think it is in the wrong place and should have been put in the top of the loadWorker_DoWork() method.
(I would have given each thread their own dbContext).
|
|
|
|
|
I was under the impression you could only have 1 datareader active at any one time, I assume EF spit uses datareader as the underlying connection type. The second connection may be being reject on that basis.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I need to save the index of all columns so that when the user opens the form again it is in the same order.I am able to get the OldDisplayIndex and NewDisplayIndex of the reordered column.But i need the new indices of all the columns after reorder in ListView.
<pre>
private void listView1_ColumnReordered(object sender, ColumnReorderedEventArgs e)
{
foreach(ColumnHeader cHeader in ListView1.Columns)
{
int iOldValue = e.OldDisplayIndex ;
int iNewValue = e.NewDisplayIndex ;
int index = cHeader.DisplayIndex;
}
}
|
|
|
|
|
|
Message Closed
modified 10-Aug-15 18:28pm.
|
|
|
|
|
Very novice question. Got a C# program from a codeproject article and can not build it in VS (Visual Studio 2010)... Would someone tell me what properties such as "target framework" I need to set? How do I find what "target framework" the project is built on? Looked at assemblyinfo.cs and there is no mention of it. Thanks in advance
|
|
|
|
|
Normally, the project from an article will include all the code necessary - including the .SLN and .CSPRJ files which define the framework version.
If it doesn't, then the best thing to do is try to contact the author - there is a forum at the bottom of the article for just that - and see if he can help.
If not, then try a version suitable for the publication date!
Sorry, but there are tens of thousands of articles (if not hundreds of thousands) produced by a huge number of people, using a huge number of environments / versions - we can't tell you anything without knowing which article it was!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks for the pointers. I appreciate it.
|
|
|
|
|
Right click on the project, select Properties. Click the Application tab. There's a drop down for Target Framework.
If it's not broken, fix it until it is
|
|
|
|
|
Thanks Kevin, but you are stating the obvious and general... I have downloaded an article and opened it with VS2010 and get error when building it... the error message is to the nature of different framework.... So how do I know which framework is used in downloaded article?
|
|
|
|
|
The SLN file will tell you. Open with an editor and look for
"Microsoft Visual Studio Solution File, Format Version XX.XX"
Then look here[^]
If it's not broken, fix it until it is
|
|
|
|
|
Thanks, I appreciate your answer and pointer link. And love you motto: If it's not broken, fix it until it is
|
|
|
|
|
NP. Let me know if that works.
My motto comes from 30 years of development... and watching ppl 'Fix' things
If it's not broken, fix it until it is
|
|
|
|