private void GenerateGetKeyValueDirect() { var method = _result.DefineMethod("GetKeyValueDirect", MethodAttr, objectType, new Type[] { objectType }); _result.DefineMethodOverride(method, handlerBaseGetKeyValueDirect); var processor = new ILBuilder(method.GetILGenerator()); if (_info.KeyMembers.Length == 1) { var h = _info.KeyMembers[0]; processor.LoadArg(1).Cast(_model); processor.GetMember(h); processor.Box(h.MemberType); } else { processor.LoadNull(); } processor.Return(); }
private void GenerateSetValuesForSelectDirectDirect(bool noLazy) { var methodName = noLazy ? "SetValuesForSelectDirectNoLazy" : "SetValuesForSelectDirect"; var method = _result.DefineMethod(methodName, MethodAttr, null, new Type[] { listKeyValuePairStringStringType }); _result.DefineMethodOverride(method, noLazy ? handlerBaseSetValuesForSelectDirectNoLazy : handlerBaseSetValuesForSelectDirect); var processor = new ILBuilder(method.GetILGenerator()); foreach (var f in _info.Members) { if (!f.Is.HasOne && !f.Is.HasMany && !f.Is.HasAndBelongsToMany) { if (noLazy || !f.Is.LazyLoad) { processor.LoadArg(1); processor.LoadString(f.Name); if (f.Name != f.MemberInfo.Name) { processor.LoadString(f.MemberInfo.Name); } else { processor.LoadNull(); } processor.NewObj(keyValuePairStringStringCtor); processor.CallVirtual(listKeyValuePairStringStringAdd); } } } processor.Return(); }