dynamic

LINQ Select from dynamic tableName string

混江龙づ霸主 提交于 2019-12-17 09:58:19
问题 I want to get list of records from an entity model (I'm using EF version 5) with a particular accountID. I'm being supplied with the tableName string (this has to be dynamic) and the accountID. I'm trying the following 2 methods but none of them is working (giving me errors on the IQueryable object 'table': PropertyInfo info = _db.GetType().GetProperty(tableName); IQueryable table = info.GetValue(_db, null) as IQueryable; var query = table.Where(t => t.AccountID == accID) .Select(t => t);

LINQ Select from dynamic tableName string

荒凉一梦 提交于 2019-12-17 09:58:05
问题 I want to get list of records from an entity model (I'm using EF version 5) with a particular accountID. I'm being supplied with the tableName string (this has to be dynamic) and the accountID. I'm trying the following 2 methods but none of them is working (giving me errors on the IQueryable object 'table': PropertyInfo info = _db.GetType().GetProperty(tableName); IQueryable table = info.GetValue(_db, null) as IQueryable; var query = table.Where(t => t.AccountID == accID) .Select(t => t);

How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)? [closed]

故事扮演 提交于 2019-12-17 09:53:09
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I'm trying to make a program which Takes the user input (let's say all of it is int ) Store it in an array without a starting size (i.e. not -> array[5]; ); and then Use the information stored in the array for whatever sinister purposes. I'm asking for help so that I can learn how

WPF Canvas, how to add children dynamically with MVVM code behind

喜你入骨 提交于 2019-12-17 08:48:26
问题 Requirement: To draw one Bitmap Image (of 1024 x 1024 pixels) and rectangle(s) based on the collection of points. The rectangle should exactly fit on the pixels location over the image. There is also some text need to be added inside the rectangle. The Image will be always only one and the rectangles will be dynamically added. Current Solution: Have a canvas with Image Control. Add the the dynamic code under the code behind file ViewImageResult.xaml.cs. private void DrawResult(int left, int

Objective C calling method dynamically with a string

偶尔善良 提交于 2019-12-17 08:34:09
问题 Im just wondering whether there is a way to call a method where i build the name of the method on the fly with a string. e.g. I have a method called loaddata -(void)loadData; to call this i would normally call it like [self loadData]; But i want to be able to call it dynamically with a string e.g. NSString *methodName = [[NSString alloc] initWithString:@"loadData"]; [self methodName]; This is a stupid example but i hope you get my point. I am using it for databinding classes that I am setting

Linq To Sql - Dynamic OrderBy - Case When

前提是你 提交于 2019-12-17 07:52:12
问题 I'm using Linq to sql and Linq Dynamic OrderBy. I know linq dynamic can do simple sorting like - orderby("column_name"). But does it support something more complex like queries with "CASE WHEN" in them ? string orderbyQuery = "(CASE WHEN (username == 100) THEN 1 ELSE 0 END) DESC)"; here is my query : var u = from u in db.users orderby(orderbyQuery) select u; the above example doesn't work! , any idea if its possible? any other way to do it? thanks 回答1: var u = from u in db.users orderby u

How to dynamically add OR operator to WHERE clause in LINQ

不羁的心 提交于 2019-12-17 07:29:00
问题 I have a variable size array of strings, and I am trying to programatically loop through the array and match all the rows in a table where the column "Tags" contains at least one of the strings in the array. Here is some pseudo code: IQueryable<Songs> allSongMatches = musicDb.Songs; // all rows in the table I can easily query this table filtering on a fixed set of strings, like this: allSongMatches=allSongMatches.Where(SongsVar => SongsVar.Tags.Contains("foo1") || SongsVar.Tags.Contains("foo2

Changing datagridview cell color dynamically

元气小坏坏 提交于 2019-12-17 06:51:36
问题 I have a dataGridView object that is populated with data. I want to click a button and have it change the color of the background of the cell. This is what I currently have foreach(DataGridViewRow row in dataGridView1.Rows) { foreach(DataGridViewColumn col in dataGridView1.Columns) { //row.Cells[col.Index].Style.BackColor = Color.Green; //doesn't work //col.Cells[row.Index].Style.BackColor = Color.Green; //doesn't work dataGridView1[col.Index, row.Index].Style.BackColor = Color.Green; //doesn

Dynamic static method call in PHP?

和自甴很熟 提交于 2019-12-17 06:33:32
问题 Please could someone experienced in PHP help out with the following. Somewhere in my code, I have a call to a public static method inside a non-instantiated class: $result = myClassName::myFunctionName(); However, I would like to have many such classes and determine the correct class name on the fly according to the user's language. In other words, I have: $language = 'EN'; ... and I need to do something like: $result = myClassName_EN::myFunctionName(); I know I could pass the language as a

Dynamically add textViews to a linearLayout

ε祈祈猫儿з 提交于 2019-12-17 06:29:50
问题 I read this somewhere here and I totally lost it, but could use some assistance. My app is pulling the column names from sqlite into an array. I want to create a textview and edit text for each one (via the size of the array), and I remember reading somewhere that you can treat the textViews variable names like an array, but I don't know where that is now. So how would I dynamically create a textView and editText for however many listings are in an array? It was something like TextView tv[] =