1. Tony Meißner
  2. SnapObjects
  3. Monday, 28 June 2021 14:07 PM UTC

is it possible to load a sqlselect from a model without params?

 

I have this structure:

[SqlParameter(name: "first", dataType: typeof(int))]
[SqlParameter(name: "second", dataType: typeof(int))]
[FromTable("mytable", Schema = "DBA")]

[SqlWhere("first = :first")]
[SqlAndWhere ("second = :second")]
public class MyClass
{
[Key]
[SqlColumn("first")]
public int First { get; set; }
[Key]
[SqlColumn("second")]
public string Second { get; set; }
...
}

 

and my service:

var builder = ModelSqlBuilder.GetBuilder<MyClass>(_dataContext)
.GetQueryBuilder(sqlselect);

builder.RemoveWhere();

List<MyClass> result = (await _dataContext.SqlExecutor.SelectAsync<MyClass>(
builder,
new object[] { },
default)).ToList();

 

but it shows me:

Missing parameter value(s).

How can i dynmacilly remove the params?

Tony Meißner Accepted Answer Pending Moderation
  1. Wednesday, 30 June 2021 09:00 AM UTC
  2. SnapObjects