我想做这样的事情
SELECT ID, X, Y, Z FROM TABLE_1
Run Code Online (Sandbox Code Playgroud)
这给我带来了类似的东西:
| IDTABLE_1 | X | Y | Z |
| 1 | a | b | c |
| 2 | d | e | f |
| 3 | g | h | i |
Run Code Online (Sandbox Code Playgroud)
我有另一个表TABLE_2,其中包含一个列,其中包含上一个表中的列名(TABLE_1):
| IDTABLE_2 | COLUMN |
| 101 | X |
| 102 | Y |
| 103 | Z |
Run Code Online (Sandbox Code Playgroud)
现在我需要将select中的所有数据插入到这个新表TABLE_3中,它必须是这样的:
| IDTABLE_3 | IDTABLE_1 | IDTABLE_2 | VALUE |
| 201 | 1 …Run Code Online (Sandbox Code Playgroud) 有没有一种方法可以在没有where子句的情况下选择非空值?我知道可以这样做
SELECT X, Y, Z
FROM T
WHERE X IS NOT NULL
Run Code Online (Sandbox Code Playgroud)
但我想知道是否有办法将null'过滤器'放在select子句中而不使用where
也许是这样的?
SELECT NOT_NULL(X), Y, Z
FROM T
Run Code Online (Sandbox Code Playgroud)
泰
我有一个带有选择值的游标,我想在取决于我是否找到任何行之后做一些事情。
recs_Table SYS_REFCURSOR;
begin
open recs_Table for
select * from table1, table2;
if recs_Table%found then
--do this
else
--do that
end if;
end;
Run Code Online (Sandbox Code Playgroud)
这似乎不起作用,有什么帮助吗?Ty
所以我得到了这段代码:
ClassA { List<ClassB> classBList;}
ClassB { List<ClassC> classCList;}
ClassC { String ID;}
Dictionary<string,int> dict;
ClassA MyObject;
Run Code Online (Sandbox Code Playgroud)
字典上的键应该与ClassC上的ID字段匹配.我想在linq上执行以下查询
List<String> matches = (from b in MyObject
from c in b.classCList
join d in dict
on c.ID equals dict.Key
select new
{
c.Value == 0 ? "YES" : "NO"
}).ToList();
Run Code Online (Sandbox Code Playgroud)
但是我收到了错误: "Invalid anonymous type member ..."
底线是......我怎样才能在select new中有条件?
编辑
如何使用扩展方法执行此查询?
有帮助吗?泰
有这个抽象类:
abstract class OrderHandler<T> : Handler where T : class
{
protected readonly Dictionary<Type, Func<BaseOrder, T>> OrderDispatcher =
new Dictionary<Type, Func<BaseOrder, T>>
{
{ typeof(OrderA), order => HandleOrder((OrderA) order) },
{ typeof(OrderB), order => HandleOrder((OrderB) order) },
{ typeof(OrderC), order => HandleOrder((OrderC) order) },
{ typeof(OrderD), order => HandleOrder((OrderD) order) },
};
public abstract T HandleOrder(OrderA order);
public abstract T HandleOrder(OrderB order);
public abstract T HandleOrder(OrderC order);
public abstract T HandleOrder(OrderD order);
}
abstract class Handler
{
public abstract Start(string …Run Code Online (Sandbox Code Playgroud) interface IComponent { /*code*/ }
interface IContent : IComponent { /*code*/ }
interface IMedia : IComponent { /*code*/ }
class A : IContent { /*code*/ }
class B : IMedia { /*code*/ }
class C : IContent, IMedia { /*code*/ }
private static T GetComponent<T>(string itemTemplate)
where T : IComponent, new ()
{
T component;
switch (itemTemplate)
{
case "template_1":
component = new A();
break;
case "template_2":
component = new B();
break;
case "template_3":
component = new C();
break;
default: …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
IEnumerable<DestinationResult> destinations =
_repository.GetDestinationData();
IEnumerable<Destination> finalDestinations =
destinations.Select(GetAdditionalDestinationInfo);
private Destination GetAdditionalDestinationInfo(DestinationResult d){ /* CODE */}
Run Code Online (Sandbox Code Playgroud)
如何仍然使用方法组调用 (Select(GetAdditionalDestinationInfo)) 并过滤掉可能从 GetAdditionalDestinationInfo 返回的 null 值(无需再次调用该方法来检查 where 子句中的 null 值)。
就像是:
IEnumerable<Destination> finalDestinations =
destinations.Select(GetAdditionalDestinationInfo != null)
Run Code Online (Sandbox Code Playgroud)