SWEETPONY
SWEETPONY
CC#
Created by SWEETPONY on 7/16/2024 in #help
✅ is there any way to delete items from the database and return the deleted list in one request?
thanks for helping
14 replies
CC#
Created by SWEETPONY on 7/16/2024 in #help
✅ is there any way to delete items from the database and return the deleted list in one request?
with DbContext.T.Where(entity => ..).ExecuteDelete() I can only delete but I need to return deleted items too
14 replies
CC#
Created by SWEETPONY on 7/16/2024 in #help
✅ is there any way to delete items from the database and return the deleted list in one request?
I think row sql is the best option here - delete from x where x.a = 1 returning *
14 replies
CC#
Created by SWEETPONY on 7/2/2024 in #help
✅ How to optimize this method?
ah I know, thanks
4 replies
CC#
Created by SWEETPONY on 7/2/2024 in #help
✅ How to optimize this method?
🙂 but how to get changes after update?
4 replies
CC#
Created by SWEETPONY on 6/21/2024 in #help
Is it possible to update public IReadOnlyList?
in the last line
12 replies
CC#
Created by SWEETPONY on 6/21/2024 in #help
Is it possible to update public IReadOnlyList?
but got an exception "Property set method not found."
12 replies
CC#
Created by SWEETPONY on 6/21/2024 in #help
Is it possible to update public IReadOnlyList?
I tried this:
var newSelections = new List<ISelectionNode>(node.SelectionSet!.Selections)
{
new FieldNode("test")
}.AsReadOnly();

var selectionSetProperty = node.GetType().GetProperty("SelectionSet");
var selectionSet = selectionSetProperty?.GetValue(node);
var selectionsProperty = selectionSet?.GetType().GetProperty("Selections");

if(selectionsProperty != null)
{
selectionsProperty.SetValue(selectionSet, newSelections);
}
var newSelections = new List<ISelectionNode>(node.SelectionSet!.Selections)
{
new FieldNode("test")
}.AsReadOnly();

var selectionSetProperty = node.GetType().GetProperty("SelectionSet");
var selectionSet = selectionSetProperty?.GetValue(node);
var selectionsProperty = selectionSet?.GetType().GetProperty("Selections");

if(selectionsProperty != null)
{
selectionsProperty.SetValue(selectionSet, newSelections);
}
12 replies
CC#
Created by SWEETPONY on 6/21/2024 in #help
Is it possible to update public IReadOnlyList?
hm
12 replies
CC#
Created by SWEETPONY on 6/19/2024 in #help
✅ how to convert Dictionary to C# object?
I can do this but only with newtonsoft:
var str = JsonConvert.SerializeObject(changes);
var obj = JsonConvert.DeserializeObject<WorkingTaskModel>(str);
var str = JsonConvert.SerializeObject(changes);
var obj = JsonConvert.DeserializeObject<WorkingTaskModel>(str);
2 replies
CC#
Created by SWEETPONY on 5/28/2024 in #help
The instance of entity type 'OptimizerInstanceEntity' cannot be tracked
but anyway it doesn't work
6 replies
CC#
Created by SWEETPONY on 5/28/2024 in #help
The instance of entity type 'OptimizerInstanceEntity' cannot be tracked
a new entity contains a list of new instances with new values but existed ids
6 replies
CC#
Created by SWEETPONY on 5/28/2024 in #help
The instance of entity type 'OptimizerInstanceEntity' cannot be tracked
entity after this method should be fine..
6 replies
CC#
Created by SWEETPONY on 5/28/2024 in #help
The instance of entity type 'OptimizerInstanceEntity' cannot be tracked
private OptimizerSettingsSetsEntity CreateEntity(OptimizerSettingsSetsModel model, OptimizerSettingsSetsEntity? entity)
{
return new OptimizerSettingsSetsEntity
{
Id = entity?.Id ?? default,
OptimizerInstances = model.OptimizerInstances?
.Select(m =>
{
var found = dbContext.OptimizerInstances.FirstOrDefault(x => x.Identity == m.Identity);
return new OptimizerInstanceEntity
{
Id = found?.Id ?? default,
Identity = m.Identity,
Url = m.Url
};
}).ToList()!,
OptimizerSettingsParameters = model.OptimizerSettingsParameters?
.Select(op => new OptimizerSettingsParameters
{
Identity = op.Identity,
Value = op.Value,
Description = op.Description
}).ToList()!,
Created = entity?.Created ?? timeProvider.GetUtcNow().DateTime,
Updated = entity == null ? null : timeProvider.GetUtcNow().DateTime,
Identity = model.Identity
};
}
private OptimizerSettingsSetsEntity CreateEntity(OptimizerSettingsSetsModel model, OptimizerSettingsSetsEntity? entity)
{
return new OptimizerSettingsSetsEntity
{
Id = entity?.Id ?? default,
OptimizerInstances = model.OptimizerInstances?
.Select(m =>
{
var found = dbContext.OptimizerInstances.FirstOrDefault(x => x.Identity == m.Identity);
return new OptimizerInstanceEntity
{
Id = found?.Id ?? default,
Identity = m.Identity,
Url = m.Url
};
}).ToList()!,
OptimizerSettingsParameters = model.OptimizerSettingsParameters?
.Select(op => new OptimizerSettingsParameters
{
Identity = op.Identity,
Value = op.Value,
Description = op.Description
}).ToList()!,
Created = entity?.Created ?? timeProvider.GetUtcNow().DateTime,
Updated = entity == null ? null : timeProvider.GetUtcNow().DateTime,
Identity = model.Identity
};
}
6 replies
CC#
Created by SWEETPONY on 5/16/2024 in #help
✅ is it okay to use try/catch for logic behavior?
thanks for helping me
12 replies
CC#
Created by SWEETPONY on 5/16/2024 in #help
✅ is it okay to use try/catch for logic behavior?
is it because the Try.... pattern doesn't throw exceptions?
12 replies
CC#
Created by SWEETPONY on 5/6/2024 in #help
✅ How to get all data without Include?
okay thanks
7 replies