select

dynamically build select clause linq

孤街醉人 提交于 2021-01-27 19:22:28
问题 class someClass { public int Id { get; set; } public string Name{ get; set; } ... public string someProperty { get; set; } } Expression<Func<someClass, object>> selector = null; selector = k => new { k.Id ,k.Name }; var serult = myData.Select(selector); // .Select(p=> new {p.Name , p.Id}) etc. This sample code is working But; Expression<Func<someClass, ???>> createSelector(string[] fields) { ... .... return ... } Expression<Func<someClass, ???>> selector = createSelector({"Name","Id"}); Is

Use STUFF with INNER JOIN Query

独自空忆成欢 提交于 2021-01-27 10:48:38
问题 I have three tables in my database. A table for Product, a table for Types and a mapping table named Prod_Type. My database is sql server that's why I cant use the group_concat function and I am using the Stuff function.My table structures were as follows ProductTable Prod_ID | Name | Brand ------- ---- ----- 1 | Name1 | Brand1 2 | Name2 | Brand2 3 | Name3 | Brand3 4 | Name4 | Brand4 5 | Name5 | Brand5 6 | Name6 | Brand6 7 | Name7 | Brand7 TypeTable Type_ID | TypeName ------- -------- 1 |

SQLite syntax for operator “ANY”

£可爱£侵袭症+ 提交于 2021-01-26 09:25:13
问题 I'm trying execute this query in SQLite: SELECT * FROM customers WHERE rating = ANY (SELECT rating FROM customers WHERE city = 'Rome'); But received this error: Query Error: near "SELECT": syntax error Unable to execute statement If I replace rating = ANY to rating IN , everything works fine. Can someone show me how ANY statement works in SQLite and what I am doing wrong? 回答1: AFAIK, SQLite doesn't have an ANY operator. You could, however, use the IN operator to get the required functionality

SQLite syntax for operator “ANY”

会有一股神秘感。 提交于 2021-01-26 09:23:00
问题 I'm trying execute this query in SQLite: SELECT * FROM customers WHERE rating = ANY (SELECT rating FROM customers WHERE city = 'Rome'); But received this error: Query Error: near "SELECT": syntax error Unable to execute statement If I replace rating = ANY to rating IN , everything works fine. Can someone show me how ANY statement works in SQLite and what I am doing wrong? 回答1: AFAIK, SQLite doesn't have an ANY operator. You could, however, use the IN operator to get the required functionality

Subset data based on presence/absence on unique samples and sample groups in R

若如初见. 提交于 2021-01-26 02:08:50
问题 I'd like to know which observations are present (>=1) in all samples (columns) and which are unique to each subset of samples ("Continent" or "Country"). For example: -df_all = would containin Obs5 (>=1 in all samples) df_Europe = would contain Obs1 (>=1 in Europe and =0 in Africa) df_Italy = would contain Obs2 (>=1 in Italy and 0 in the rest) etc... For the first one can use: row_sub = apply(df, 1, function(row) all(row !=0 )) dff <- df[row_sub,] BUT is there a way of coding it as a loop,

Subset data based on presence/absence on unique samples and sample groups in R

白昼怎懂夜的黑 提交于 2021-01-26 02:08:16
问题 I'd like to know which observations are present (>=1) in all samples (columns) and which are unique to each subset of samples ("Continent" or "Country"). For example: -df_all = would containin Obs5 (>=1 in all samples) df_Europe = would contain Obs1 (>=1 in Europe and =0 in Africa) df_Italy = would contain Obs2 (>=1 in Italy and 0 in the rest) etc... For the first one can use: row_sub = apply(df, 1, function(row) all(row !=0 )) dff <- df[row_sub,] BUT is there a way of coding it as a loop,

Subset data based on presence/absence on unique samples and sample groups in R

你说的曾经没有我的故事 提交于 2021-01-26 02:07:30
问题 I'd like to know which observations are present (>=1) in all samples (columns) and which are unique to each subset of samples ("Continent" or "Country"). For example: -df_all = would containin Obs5 (>=1 in all samples) df_Europe = would contain Obs1 (>=1 in Europe and =0 in Africa) df_Italy = would contain Obs2 (>=1 in Italy and 0 in the rest) etc... For the first one can use: row_sub = apply(df, 1, function(row) all(row !=0 )) dff <- df[row_sub,] BUT is there a way of coding it as a loop,

Can using multiple JSON_VALUE-s in MSSQL query harm performance

為{幸葍}努か 提交于 2021-01-24 19:04:49
问题 I have table in sql server database which have column of json type. Table - SomeTable Id | Properties 1 | {"field1":"value1", "field2":"value2", "field3":"value3", "field4":"value4"} 2 | {"field1":"value1", "field2":"value2", "field3":"value3", "field4":"value4"} ...|... I wrote select query which selects value of each field separately: SELECT JSON_VALUE(Properties, '$.field1') as field1, JSON_VALUE(Properties, '$.field2') as field2, JSON_VALUE(Properties, '$.field3') as field3, JSON_VALUE

Can using multiple JSON_VALUE-s in MSSQL query harm performance

元气小坏坏 提交于 2021-01-24 18:58:33
问题 I have table in sql server database which have column of json type. Table - SomeTable Id | Properties 1 | {"field1":"value1", "field2":"value2", "field3":"value3", "field4":"value4"} 2 | {"field1":"value1", "field2":"value2", "field3":"value3", "field4":"value4"} ...|... I wrote select query which selects value of each field separately: SELECT JSON_VALUE(Properties, '$.field1') as field1, JSON_VALUE(Properties, '$.field2') as field2, JSON_VALUE(Properties, '$.field3') as field3, JSON_VALUE

Can using multiple JSON_VALUE-s in MSSQL query harm performance

谁说我不能喝 提交于 2021-01-24 18:56:43
问题 I have table in sql server database which have column of json type. Table - SomeTable Id | Properties 1 | {"field1":"value1", "field2":"value2", "field3":"value3", "field4":"value4"} 2 | {"field1":"value1", "field2":"value2", "field3":"value3", "field4":"value4"} ...|... I wrote select query which selects value of each field separately: SELECT JSON_VALUE(Properties, '$.field1') as field1, JSON_VALUE(Properties, '$.field2') as field2, JSON_VALUE(Properties, '$.field3') as field3, JSON_VALUE