dynamic

SQL Server 2008 Updating VarChar Column with a UDF?

馋奶兔 提交于 2019-12-12 17:25:50
问题 I have a scalar function that takes a two variables @input1 @input2 and it returns the value of @input1 and @input2 (actual thing is more complex but this distills the idea). I want to update all rows in a table column using this function, passing the value 'abc ' for @input1 and using the column name in @input2, so my update statement would look something like: update mytable set mycolumn = (select dbo.myfunc( 'abc ' , mycolumn ) ) -- prepend the literal 'abc ' to every row for column

Why is RuntimeBinderException thrown when generic parameter is private?

做~自己de王妃 提交于 2019-12-12 17:23:44
问题 When a method is called with a dynamic parameter of the form Foo<Bar> , a RuntimeBinderException is thrown when Bar is private. Why? (See comment in Run method of Test1 below.) public class Test1 { public void Run() { dynamic publicList = ListProvider.GetPublic(); DoSomething(publicList); dynamic privateList = ListProvider.GetPrivate(); DoSomething(privateList); // Microsoft.CSharp.RuntimeBinder.RuntimeBinderException } private void DoSomething<T>(List<T> list) { } static private class

How to aggregate akka-http routes using a trait?

回眸只為那壹抹淺笑 提交于 2019-12-12 16:48:26
问题 I am trying to aggregate routes using a trait at runtime, so far I have object SMController { def aggregateRoutes(actorSystem: ActorSystem): List[Route] = { val runtimeMirror = universe.runtimeMirror(getClass.getClassLoader) val reflections = new Reflections("com.example.api") val subclasses = reflections.getSubTypesOf(classOf[Routable]) val routesList = new ListBuffer[Route]() for (i <- subclasses) { val module = runtimeMirror.staticModule(i.getName) val obj = runtimeMirror.reflectModule

How to override get accessor of a dynamic object's property

倾然丶 夕夏残阳落幕 提交于 2019-12-12 16:24:12
问题 Let's suppose I have the following class: public class Person { public string Name { get; set; } public string Surname { get; set; } public string FullName { get { return Name + " " + Surname; } } } The following block: Person person = new Person(); person.Name = "Matt"; person.Surname = "Smith"; return person.FullName; would return Matt Smith . Let's change our Person type to a dynamic ExpandoObject . The code would look like this: dynamic person = new ExpandoObject(); person.Name = "Matt";

Query mongodb collection as dynamic

送分小仙女□ 提交于 2019-12-12 16:19:15
问题 I'm saving a dynamic object in my database but I would also like to retrieve it as a dynamic object. How can this be done? I tried it like so: public dynamic GetItemById(ObjectId id) { dynamic result = Db.GetCollection<dynamic>("Items").Find(x => x.Id == id).FirstOrDefaultAsync().Result; return result; } But this gives me the following error: CS1963 An expression tree may not contain a dynamic operation I know this can be fixed by using a typed object instead of a dynamic one. But I don't

Zend ACL Dynamic Assertion

无人久伴 提交于 2019-12-12 16:12:14
问题 I want to restrict my users to edit/delete only the comments which they added. I found an example on youtube by a guy named intergral30 and followed his instruction. And now my admin account has the possibility to edit/delete everything, but my user has no access to his own comment. Here's the code: Resource class Application_Model_CommentResource implements Zend_Acl_Resource_Interface{ public $ownerId = null; public $resourceId = 'comment'; public function getResourceId() { return $this-

Counting non blank cell results without looping in Excel VBA — e.g., with Specialcells

我们两清 提交于 2019-12-12 16:04:25
问题 Here is the code I'm trying to count with in VBA, hoping to return a count return variable of "3" from 'FormulaResultCount'. Why can't I count what is visibly returned by the formulas within each cell; from the grey box (see photo below)? Sub countNonBlanks() Worksheets("Sheet1").Select Range("C:C").Select FormulaResultCount = Selection.SpecialCells(xlCellTypeFormulas).Count 'SpecialCells options from MSFT ' xlCellTypeAllFormatConditions. Cells of any format -4172 ' xlCellTypeAllValidation.

Why reflection does not find property

醉酒当歌 提交于 2019-12-12 15:04:53
问题 I have the class: class Person { public string Name { get { return "Antonio"; } } } and the Code: IEnumerable<object> uncknownObject; uncknownObject = new ObservableCollection<Person>( ); var observCol = uncknownObject.GetType( ); var x = ( ( dynamic )observCol ).GenericTypeArguments[ 0 ]; var y = observCol.GetProperty( "GenericTypeArguments" ); var instance = ( Person )Activator.CreateInstance( x ); Console.WriteLine( instance.Name ); // Print Antonio!!! why does y == null ? Note the picture

Dynamic json object with numerical keys

旧巷老猫 提交于 2019-12-12 15:03:42
问题 I have a json object which I converted to dynamic C# object with help of this answer. It works just fine, but trouble is that this object has numerical keys. For instance, var jsStr = "{address:{"100": {...}}}"; So I can't wirte dynObj.address.100 And, as I know, I can't use indexers to get this object like this dynObj.address["100"] Please explain to me how I can get this working. 回答1: As far as I can see from the source code he resolves the properties through a private dictionary, so you

Dynamic LINQ querying of an ExpandoObject?

纵饮孤独 提交于 2019-12-12 14:13:34
问题 Is there any way to use the LINQ dynamic query library (System.Linq.Dynamic) to evaluate a condition based on the properties of an ExpandoObject? The following code throws an exception on the " var e... " line, saying "No property or field 'Weight' exists in type ExpandoObject":- const string TestCondition = "MyStateBag.Foo >= 50 && MyStateBag.Bar >= 100"; dynamic myStateBag = new ExpandoObject(); myStateBag.Foo = 70; myStateBag.Bar = 100; var p = Expression.Parameter(typeof(ExpandoObject),