npoco

Executing Oracle function and getting back a return value

廉价感情. 提交于 2020-03-06 03:14:28
问题 I am using NPoco ORM and trying to get a result from Oracle function. I have tried: public string GetData(int param1, int param2) { var command = "PKG_SOMEPACKAGE.SET_DATA( @p_param1, @p_param2);"; var sql = Sql.Builder.Append(command, new { p_param1 = 10, p_param2 = 20 }); string result = this.Db.ExecuteScalar<string>(sql); return result; } But it doesn't work and returns ORA-00900: invalid SQL statement The Oracle function looks something like: function SET_DATA ( p_param1 IN NUMBER, p

Is it normal for NPoco/PetaPoco Fetch() to get all data and then filter client side?

淺唱寂寞╮ 提交于 2019-12-23 17:30:05
问题 I've noticed a huge difference in how NPoco (or PetaPoco) works depending on which function you call when you are using LINQ. For instance compare Fetch() which Query() which both appear to do the same thing: A : Fetch<EntryImage>().Where(t => t.EntryType == type && t.EntryID == entryID); B : Query<EntryImage>().Where(t => t.EntryType == type && t.EntryID == entryID); A returns every row in the table (10,000+) and then filters client side. B returns just the one row I'm expecting. I find this

OrderBy extension method for NPoco.Linq

夙愿已清 提交于 2019-12-12 17:16:03
问题 I want to use OrderBy("columnName"). I see that it is possible by writing an extension method or using reflection. I am using NPoco and I am unable to write an extension method. IQueryProvider<Sample> query = DbConnection.Query<Sample>(); I want to do: var res = query.OrderByField("columnName"); I want to use something similar to this: public static IQueryable<T> OrderByField<T>(this IQueryable<T> q, string SortField, bool Ascending) { var param = Expression.Parameter(typeof(T), "p"); var

How to use Npoco FetchOneToMany?

安稳与你 提交于 2019-12-07 17:55:35
问题 I am trying to use Npoco but running into some problems with FetchOneToMany I have a sql statement that joins 2 tables together and I output all the columns. [TableName("TableA")] [PrimaryKey("Id")] public class TableA { public int Id { get; set; } public DateTime EffectiveDate { get; set; } public IList<TableB> TableBs { get; set; } } [TableName("TableB")] [PrimaryKey("TableBId")] public class TableB { public int TableBId { get; set; } public int SomeNumber { get; set; } public int Id { get;

How do I use the SQL WHERE IN construct with PetaPoco?

非 Y 不嫁゛ 提交于 2019-11-30 11:48:27
问题 I have a database table named Tags (Id, Name) from which I would like to select the ones where the name matches a name in a list. In SQL I would use something like: Select * from Tags Where Name In ('Name1', 'Name2', 'xxx...) But now using PetaPoco in an ASP.Net MVC3 project I'm stuck figuring out how to do it properly. So far I've tried: var tagsToFind = new string[] { "SqlServer", "IIS" }; var sql = PetaPoco.Sql.Builder.Select("*").From("Tags").Where("Name in (@0)", tagsToFind); var result

How do I use the SQL WHERE IN construct with PetaPoco?

扶醉桌前 提交于 2019-11-30 01:26:51
I have a database table named Tags (Id, Name) from which I would like to select the ones where the name matches a name in a list. In SQL I would use something like: Select * from Tags Where Name In ('Name1', 'Name2', 'xxx...) But now using PetaPoco in an ASP.Net MVC3 project I'm stuck figuring out how to do it properly. So far I've tried: var tagsToFind = new string[] { "SqlServer", "IIS" }; var sql = PetaPoco.Sql.Builder.Select("*").From("Tags").Where("Name in (@0)", tagsToFind); var result = db.Query<Tag>(sql); Which results in the following SQL, where only the first name in my list of