entity-framework

Chaining OR conditions in EF 5.0

人走茶凉 提交于 2021-02-07 06:23:41
问题 I will preface this with I'm actively searching for the solution to this problem but figured I might short cut some research and development time if someone here on stack has already figured this out. (I have found nothing online so here goes) We have a case in an application framework we are building where we need the capability to take in a set of Predicates ( List<Expression<Func<T,bool>>> ) and parse it in a search framework. Right now we have the capability to filter in this way being

Chaining OR conditions in EF 5.0

浪尽此生 提交于 2021-02-07 06:23:36
问题 I will preface this with I'm actively searching for the solution to this problem but figured I might short cut some research and development time if someone here on stack has already figured this out. (I have found nothing online so here goes) We have a case in an application framework we are building where we need the capability to take in a set of Predicates ( List<Expression<Func<T,bool>>> ) and parse it in a search framework. Right now we have the capability to filter in this way being

The data reader is incompatible with the specified model

感情迁移 提交于 2021-02-07 05:56:04
问题 I am running a stored procedure by adding it in existing model (edmx) by Add--> function Import. I received the following error. The data reader is incompatible with the specified 'dbModel.stored_procedure_Result'. A member of the type, 'UID', does not have a corresponding column in the data reader with the same name. _Result class of the Modle is as follows public partial class stored_procedure_Result { public int UID { get; set; } public int SYSTEM_ID { get; set; } public byte ACTIVE { get;

Scalar Value from stored procedure via Entity Framework

旧巷老猫 提交于 2021-02-07 05:47:28
问题 I have found a few articles like this one: http://devtoolshed.com/using-stored-procedures-entity-framework-scalar-return-values Yet when I take the step to create a function import for a int32 scalar, this is what gets generated: public ObjectResult<Nullable<global::System.Int32>> MyStoredProcedure(Nullable<global::System.Int32> orderId) { ObjectParameter orderIdParameter; if (orderId.HasValue) { orderIdParameter = new ObjectParameter("OrderId", orderId); } else { orderIdParameter = new

How to prevent from DataAnnotations Attributes being deleted in DataBase First Model

╄→尐↘猪︶ㄣ 提交于 2021-02-07 05:43:04
问题 I have my asp.net mvc 3 application with entity framework and i used the Database First model to set it up. My Steps below: 1. Genarated a database with tables 2. Created ADO.NET Entity Data Model file (.edmx) and imported the tables 3. inside the design i added a Code Generation item and used ADO.NET DbContext Generator 4. a Model1.tt holder as been made with all of the tables Models I have edited the models and updated them with DataAnnotations Attributes (just for the example a well known

Can I inject dependency into migration (using EF-Core code-first migrations)?

强颜欢笑 提交于 2021-02-07 05:12:13
问题 I tried to inject IConfiguration into the migration (in constructor), and got exception: "No parameterless constructor defined for this object." any workaround? 回答1: you cannot, the migrations need to be able to run outside the context of your application. Since the Entity-framework command-line tool analyzes your code but does not run the startup.cs class. Also it is not advisable. your migrations should be plain simple and not depend on anything. if it would, it could lead to major runtime

Can I inject dependency into migration (using EF-Core code-first migrations)?

偶尔善良 提交于 2021-02-07 05:06:43
问题 I tried to inject IConfiguration into the migration (in constructor), and got exception: "No parameterless constructor defined for this object." any workaround? 回答1: you cannot, the migrations need to be able to run outside the context of your application. Since the Entity-framework command-line tool analyzes your code but does not run the startup.cs class. Also it is not advisable. your migrations should be plain simple and not depend on anything. if it would, it could lead to major runtime

Route Id overrides Model.Id

佐手、 提交于 2021-02-07 03:54:34
问题 I have a route like this: Conference/Committees/1 And within that page, it cycles through the Committees for a Conference (where the Conference Id = 1). I have a partial view that renders an edit style page for a selected committee, with a route like this: Conference/Committees/1?committeeId=2 In debug, the model data is correct, and the Committee has an Id = 2. However, when I use the following Razor statement: @Html.HiddenFor(model => model.Id) with the following model: @model munhq.Models

Route Id overrides Model.Id

筅森魡賤 提交于 2021-02-07 03:48:00
问题 I have a route like this: Conference/Committees/1 And within that page, it cycles through the Committees for a Conference (where the Conference Id = 1). I have a partial view that renders an edit style page for a selected committee, with a route like this: Conference/Committees/1?committeeId=2 In debug, the model data is correct, and the Committee has an Id = 2. However, when I use the following Razor statement: @Html.HiddenFor(model => model.Id) with the following model: @model munhq.Models

Route Id overrides Model.Id

久未见 提交于 2021-02-07 03:46:35
问题 I have a route like this: Conference/Committees/1 And within that page, it cycles through the Committees for a Conference (where the Conference Id = 1). I have a partial view that renders an edit style page for a selected committee, with a route like this: Conference/Committees/1?committeeId=2 In debug, the model data is correct, and the Committee has an Id = 2. However, when I use the following Razor statement: @Html.HiddenFor(model => model.Id) with the following model: @model munhq.Models