idictionary

<Map> = IDictionary

一世执手 提交于 2019-12-12 05:39:36
问题 I have 3 entities: class User {id,name...} class UserUrl {id,user_id,url,url_type_id} class UrlType {id,name} My mapping: <class name="User" table="Users" lazy="false"> <id name="id" type="Int32" column="id"> <generator class="identity" /> </id> <property name="name" column="name" type="String"/> <map name="Urls" table="UserUrl"> <key column="user_id"></key> <index-many-to-many class="UrlType" column="url_type_id"/> <one-to-many class="UserUrl"/> </map> </class> <class name="UserUrl" table=

NHibernate QueryOver the values of a dictionary(map)

白昼怎懂夜的黑 提交于 2019-12-11 06:28:56
问题 For a project i'm working on, i need to query over the values of a mapped dictionary in Nhibernate. Something like SELECT * FROM EntityWithDictionary WHERE EntityWithDictionary in (select EntityFromDictionaryId FROM Dictionary where value = 'testvalue') I've tried several things but I can't figure out how i can do it. Here is what i have. Entity public class EntityWithDictionary { public virtual Guid Id { get; set; } public virtual string Description { get; set; } private IDictionary<string,

using a generic Dictionary and or sorting with IDictionary

…衆ロ難τιáo~ 提交于 2019-12-11 01:57:41
问题 I have a dictionary where the value is determined at runtime. I can create it as an IDictionary and add to it fine however I can't sort. Is there a way to create it as a Dictionary so I can access OrderBy or is there another way to sort it as an IDictionary ? void func (PropertyDescriptor prop) { //Create dynamic dictionary Type GenericTypeDictionary = typeof(Dictionary<,>); Type SpecificTypeDictionary = GenericTypeDictionary.MakeGenericType(typeof(T), prop.PropertyType); var

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary

▼魔方 西西 提交于 2019-12-10 15:08:52
问题 I receive the above error message when performing a unit test on a method. I know where the problem is at, I just don't know why it's not present in the dictionary. Here is the dictionary: var nmDict = xelem.Descendants(plantNS + "Month").ToDictionary( k => new Tuple<int, int, string>(int.Parse(k.Ancestors(plantNS + "Year").First().Attribute("Year").Value), Int32.Parse(k.Attribute("Month1").Value), k.Ancestors(plantNS + "Report").First().Attribute("Location").Value.ToString()), v => { var

Is there a limit to entries in a Dictionary<>?

大城市里の小女人 提交于 2019-12-10 12:56:49
问题 I have about 3000 different files I need to organize, and retrieve at different times during the game. I created my own struct of variables. I was thinking about creating a "Dictionary " at the beginning of my application, and simply loading all my files before the game starts. I'm wondering about performance: will a dictionary with this many entries cause my application to be slow? Would a large dictionary make "TryGetValue" and "ContainsKey" run slower? thanks for the advice! 回答1:

Dictionary.ContainsKey() - How does it work?

巧了我就是萌 提交于 2019-12-10 12:28:57
问题 I've read the MSDN documentation on how Dictionary.ContainsKey() works, but I was wondering how it actually makes the equality comparison? Basically, I have a dictionary keyed to a reference type* and I want the ContainsKey() method to check a certain property of that reference type as its basis for determining if the key exists or not. For example, if I had a Dictionary(MyObject, int) and MyObject has a public property (of int ) called "TypeID", could I get ContainsKey(MyObject myObject) to

Passing IDictionary object to Web service

纵然是瞬间 提交于 2019-12-04 05:26:46
问题 In my asmx file, I have [WebMethod] [ScriptMethod] public void Method(IDictionary<string, CustomClass> objectOfCustomClass) { //do stuff } custom class is defined as: public class CustomClass { public string Prop1 { get; set; } public string Prop2 { get; set; } } All goes well and the web service is being successfully consumed from Jquery ajax method. Recently I decided to test and try and access it from the direct URL such as http://localhost/Services.asmx/Method and I get this message

Getting values of a generic IDictionary using reflection

試著忘記壹切 提交于 2019-12-03 05:19:24
问题 I have an instance that implements IDictionary<T, K> , I don't know T and K at compiletime, and want to get all elements from it. I don't want to use IEnumerable for some reason, which would be the only non-generic interface implemented by IDictionary . Code I have so far: // getting types Type iDictType = instance.GetType().GetInterface("IDictionary`2"); Type keyType = iDictType.GetGenericArguments()[0]; Type valueType = iDictType.GetGenericArguments()[1]; // getting the keys IEnumerable

IXmlSerializable Dictionary problem

女生的网名这么多〃 提交于 2019-12-01 20:28:13
问题 I was trying to create a generic Dictionary that implements IXmlSerializable (credit to Charles Feduke). Here is my trial: Sub Main() Dim z As New SerializableDictionary(Of String, String) z.Add("asdf", "asd") Console.WriteLine(z.Serialize) End Sub Result: <?xml version="1.0" encoding="utf-16"?><Entry key="asdf" value="asd" /> I placed a breakpoint on top of the WriteXml method and I see that when it stops, the writer contains no data at all, and IMHO it should contain the root element and

IXmlSerializable Dictionary problem

荒凉一梦 提交于 2019-12-01 18:55:16
I was trying to create a generic Dictionary that implements IXmlSerializable (credit to Charles Feduke ). Here is my trial: Sub Main() Dim z As New SerializableDictionary(Of String, String) z.Add("asdf", "asd") Console.WriteLine(z.Serialize) End Sub Result: <?xml version="1.0" encoding="utf-16"?><Entry key="asdf" value="asd" /> I placed a breakpoint on top of the WriteXml method and I see that when it stops, the writer contains no data at all, and IMHO it should contain the root element and the xml declaration. <Serializable()> _ Public Class SerializableDictionary(Of TKey, TValue) : Inherits