Search Results

Search found 13429 results on 538 pages for 'model reject'.

Page 102/538 | < Previous Page | 98 99 100 101 102 103 104 105 106 107 108 109  | Next Page >

  • How to render the properties of the view model's base class first when using ViewData.ModelMetadata.

    - by Martin R-L
    When I use the ViewData.ModelMetadata.Properties in order to loop the properties (with an additional Where(modelMetadata => modelMetadata.ShowForEdit && !ViewData.TemplateInfo.Visited(modelMetadata))), and thereby create a generic edit view, the properties of the view model's base class are rendered last. Is it possible to use a clever OrderBy() or is there another way to first get the properties of the base class, and then the sub class'? Reverse won't do the trick since the ordering of each class' properties is perfectly fine. A workaround would of course be composition + delegation, but since we don't have mixins, it's too un-DRY IMHO, why I seek a better solution if possible.

    Read the article

  • Limit JavaScript and CSS files on ASP.NET MVC 2 Master Page based on Model and View content

    - by Zack Peterson
    I want to include certain .js and .css files only on pages that need them. For example, my EditorTemplate DateTime.ascx needs files anytimec.js and anytimec.css. That template is applied whenever I use either the EditorFor or EditorForModel helper methods in a view for a model with a DateTime type value. I've put this condition into the <head> section of my master page. It checks for a DateTime type property in the ModelMetadata. <% if (this.ViewData.ModelMetadata.Properties.Any(p => p.ModelType == typeof(DateTime))) { %> <link href="../../Content/anytimec.css" rel="stylesheet" type="text/css" /> <script src="../../Scripts/anytimec.js" type="text/javascript"></script> <% } %> This has two problems: Fails if I have nested child models of type DateTime Unnecessarily triggered by views without EditorFor or EditorForModel methods (example: DisplayForModel) How can I improve this technique?

    Read the article

  • CakePHP: Same model, set up per form validation rules?

    - by mwaterous
    I have a single model in CakePHP that has multiple forms on different pages of the site that I would like to validate differently even where the field name is the same - I have discovered that you can set 'on' to create|update which has been a handy discovery but I am wondering if there is any other way of explicitly declaring rules based on the form that was submitted? Just to rephrase for clarity, form a and form b contain fields of the same name, but if form a is submitted the fields in question should be validated differently than if they were submitted from form b. Possible?

    Read the article

  • ruby on rails: How do I access variable data in a url parameter passed to a model?

    - by bandhunt
    I have a variable called "account_type" passed from a rails form and need to access the value in the corresponding model. I can check if :account_type exists as a symbol, but where does the stored data come into play? Is there something I need to do in the controller? This code gives an undefined method 'account_type' error. validates_format_of :name, :with => /^[a-z0-9_]+$/i, :on => :create if account_type == 2 If I use a symbol then it doesn't give an error, but a symbol will never equal 2 validates_format_of :name, :with => /^[a-z0-9_]+$/i, :on => :create if :account_type == 2 It's confusing that you can validate the format of a symbol (like :name above) when :name only seems to be a reference with nothing stored in it. Thanks!

    Read the article

  • How to register a model in django-tagging anywhere not in the applications?

    - by culebrón
    Is it possible to register a model in django-tagging not in tagging app, nor in my app? The standard way is to edit apps/myapp/models.py this way: from apps import tagging tagging.register(MyModel) I want to keep both applications without changes, for example, to be able to pull new versions and just replace them. So I tried putting this into project settings.py, in the end, but of course this fails. from apps.myapp.models import MyModel from apps import tagging tagging.register(MyModel) (This fails when importing MyModel.) Any other way?

    Read the article

  • [Django] How to find out whether a model's column is a foreign key?

    - by codethief
    I'm dynamically storing information in the database depending on the request: // table, id and column are provided by the request table_obj = getattr(models, table) record = table_obj.objects.get(pk=id) setattr(record, column, request.POST['value']) The problem is that request.POST['value'] sometimes contains a foreign record's primary key (i.e. an integer) whereas Django expects the column's value to be an object of type ForeignModel: Cannot assign "u'122'": "ModelA.b" must be a "ModelB" instance. Now, is there an elegant way to dynamically check whether b is a column containing foreign keys and what model these keys are linked to? (So that I can load the foreign record by it's primary key and assign it to ModelA?) Or doesn't Django provide information like this to the programmer so I really have to get my hands dirty and use isinstance() on the foreign-key column?

    Read the article

  • How Do I insert Data in a table From the Model MVC?

    - by user54197
    I have data coming into my Model, how do I setup to insert the data in a table? public string Name { get; set; } public string Address { get; set; } public string City { get; set; } public string State { get; set; } public string Zip { get; set; } public Info() { using (SqlConnection connect = new SqlConnection(connections)) { string query = "Insert Into Personnel_Data (Name, StreetAddress, City, State, Zip, HomePhone, WorkPhone)" + "Values('" + Name + "','" + Address + "','" + City + "','" + State + "','" + Zip + "','" + ContactHPhone + "','" + ContactWPhone + "')"; SqlCommand command = new SqlCommand(query, connect); connect.Open(); command.ExecuteNonQuery(); } } The Name, Address, City, and so on is null when the query is being run. How do I set this up?

    Read the article

  • When saving to a model, created and modified aren't automatically populated by CakePHP. Using SQL Se

    - by bakerjr
    Hi when saving to a model, my created and modified fields aren't automatically populated by CakePHP. It was automatically populated when I was using MySQL but now it isn't. I'm not using NOW() back when I was still using MySQL. Why is it? Also when a field's value is not set 'NULL' (with quotes) is inserted causing errors because SQL Server says I can't insert a string to a field of type smallint/date etc. How do I fix this? Thanks in advance!

    Read the article

  • Building a wiki like data model in rails question.

    - by lillq
    I have a data model in which I would like to have an item that has a description that can be edited. I would like to also keep track of all edits to the item. I am running into issues with my current strategy, which is: class Item < ActiveRecord::Base has_one :current_edit, :class_name => "Edit", :foreign_key => "current_edit_id" has_many :edits end class Edit < ActiveRecord::Base belongs_to :item end Can the Item have multiple associations to the same class like this? I was thinking that I should switch to keeping track of the edit version in the Edit object and then just sorting the has_many relationship base on this version.

    Read the article

  • Ruby on Rails: How best to escape a string in a model?

    - by williamjones
    I want my application to sanitize html on input rather than on display, so that the fields saved into the database are sanitized. I've been doing this with strip_tags, and it was working great. However, this has the downside that it means the user can't input anything that's bracketed with < and . How can I tell Rails in the model to securely escape tags before saving them to the database? I'd like to not have to call h on the sanitized fields again before using them in the views.

    Read the article

  • Ruby on Rails: Simple way to select all records of a nested model?

    - by Josh Pinter
    Just curious, I spent an embarrassing amount of time trying to get an array of all the records in a nested model. I just want to make sure there is not a better way. Here is the setup: I have three models that are nested under each other (Facilities Tags Inspections), producing code like this for routes.rb: map.resources :facilities do |facilities| facilities.resources :tags, :has_many => :inspections end I wanted to get all of the inspections for a facility and here is what my code ended up being: def facility_inspections @facility = Facility.find(params[:facility_id]) @inspections = [] @facility.tags.each do |tag| tag.inspections.each do |inspection| @inspections << inspection end end end It works but is this the best way to do this - I think it's cumbersome. Thanks in advance. Josh

    Read the article

  • Does retrieving an object from Doctrine2 cause __construct() of the model class to run?

    - by jiewmeng
    When I retrieve an object say by $em->find('Application\Models\User', 1); or other methods like DQL, findBy*() cause the __construct() of the model class to run? I am having a problem where I set variables there like reference to EntityManager and I find that its not set. I tried putting a die() in __construct() and it doesn't halt the application. Can I say that if I want to set other properties/fields like EntityManager $em I have to do it some other way? Perhaps something like protected function getEm() { if (!isset($this->em)) { $this->em = \Zend_Registry::get('em'); } return $this->em; }

    Read the article

  • Is there any reason why someone would want to create an Core Data model programmatically?

    - by mystify
    I wonder in which cases it would be good to make an NSManagedObjectModel completely programmatically, with NSEntityDescription instances and all this stuff. I'm that kind of person who prefers to code programmatically, rejecting Interface Builder. But when it comes to Core Data, I have a hard time figuring out why I should kill my time NOT using the nice Xcode Data Modeler tool. And since data models are stuck to a given state (except when you want to do some ugly migration operations where thinks probably go wrong and users get mad, really mad), I see no big sense in a data model that's made programmatically for the purpose of changing it all the time. Did I miss something?

    Read the article

  • How do I construct a 3D model of a room from 2 stereo cameras? What is the determining factor to an

    - by yasumi
    Currently, I have extracted depth points to construct a 3D model from 2 stereo cameras. The methods I have used are openCV graphCut method and a software from http://sourceforge.net/projects/reconststereo/. However, the generated 3D models are not very accurate, which leads me to question: 1) What is the problem with pixel-based method? 2) Should I change my pixel-based method to feature-based or object-recognition-based method? Is there a best method? 3) Are there any other ways to do such reconstruction? Additionally, the depth extracted comes only from 2 images. What if I am turning the camera 360 degrees to obtain a video? Looking forward to suggestion on how to combine this depth information. Thank you very much :)

    Read the article

  • How do I create a collection_select in the View of a model that belongs_to another?

    - by Angela
    In the _form for creating a new Contact, I want to be able to create a drop-down which allows the User to select the Campaign the Contact will belong to. In the controller, I created a collection called @campaigns. And I tried to use the following but not getting it to work: <p> <%= f.label :campaign_id %><br /> <%= f.collection_select(:contact, :campaign_id, @campaigns, :id, :name) %> </p> Basically, I want to display the available :name of the campaigns, and then submit the campaign_id associated with the selected campaign to the Contact model when it gets saved.

    Read the article

  • Model View Presenter plus ASP.NET Web Service; where does the asmx live?

    - by Dirk
    I've been slowly transitioning from a traditional web forms architecture to the MVP pattern (Passive View). So far, it's been fairly easy to implement b/c the views I've dealt with have all employed a classic PostBack model. However, I've come across my first view that will refresh portions of itself via web services. I can't grok where the web service should live (Presenter I think) or how to expose that asmx end point to my View while still maintaining the clean separation of concerns/testability that MVP affords me. I've searched far and wide for some examples on how this might be implemented and have come up with nothing. Please help!

    Read the article

  • Is there an difference between transient properties defined in the data model, or in the custom subc

    - by mystify
    I was reading that setting the value of a transient property always results in marking the managed object as "dirty". However, what I don't get is this: If I make a subclass of NSManagedObject and use some extra properties which I don't need to be persistet, how does Core Data know about them and how can it mark the object as dirty when I access these? Again, they're not defined in the data model, so Core Data has no really good hint that they are there. Or does Core Data use some kind of introspection to analyze my custom class and figure out what properties I have in there?

    Read the article

  • How do I obtain an HtmlHelper<TModel> instance for a model in ASP.NET MVC?

    - by DanM
    Let's say I have an Index view. The model I pass in is actually a collection of models, so the Html property is of type HtmlHelper<List<MyModel>>. If I want to call extension methods (e.g., Display() or DisplayFor() on the individual items in the list, however, I think I need to obtain an HtmlHelper<MyModel>. But how? I tried using the HtmlHelper<TModel> constructor, which looks like this: HtmlHelper<TModel>(ViewContext, IViewDataContainer) But I'm not having any luck with that. I don't know how to obtain the IViewDataContainer for the item, and the documentation on these things is very sparse. A lot of magic apparently happens when I do... return View(List<MyModel>); ...in my controller. How do I recreate that magic on individual items in a list/collection?

    Read the article

  • How can I use edit_in_place on three different models from a View for a model those three belong_to?

    - by Angela
    I have a model called Campaign. In the controller, I do the following to list, in order, the three Models that belong_to a Campaign: <% @campaign_events = campaign_events %> <% @campaign_events.each do |campaign_event| %> <% model_name = campaign_event.class.name.tableize.singularize %> <p> <%= link_to campaign_event.title, send("#{model_name}_path", campaign_event) %> <span class='model_name'>(<%= model_name.capitalize %>)</span> <%= campaign_event.days %> Days </p> <% end %> campaign_event is a campaign_helper defined as: module CampaignsHelper def campaign_events return (@campaign.calls + @campaign.emails + @campaign.letters).sort{|a,b| a.days <=> b.days} end end I want to be able to click on the numerical value for Days when looking at the view/campaign/show and edit the value for :days (in this case, displayed as campaign_event.days

    Read the article

  • How can I use edit_in_place in the show of a different model in Rails?

    - by Angela
    I have a model Campaign and the campaign/show goes through a loop of the Emails. Campaign has_many Emails. <h2>Emails to Send Today</h2> <% for email in @campaign.emails %> <p><strong>Email: </strong><%= link_to email.title, email_path(email) %> sent after <%= distance_of_time_in_words(email.days.days) %></p> <% end %> I would like to be able to edit in place the subject and/or the email.days value from the Campaign/show page. How do I do that? (Added complexity, these are clickable links).

    Read the article

  • How do I put logic in a View a scope or method in a Model?

    - by Angela
    I have the following in the view: <% unless contact_email.statuses.empty?%> (<%= contact_email.statuses.find(:last).status%>) <% end %> contact_email is an instance of a specific model. Could I do something like this? class ContactEmail < ActiveRecord::Base attr_accessible :contact_id, :email_id, :status, :subject, :body, :date_created, :date_sent def status unless contact_email.statuses.empty? contact_email.statuses.find(:last).status end end end is there a better way to do this? is there a way to use the || operator for a default if empty? Basically, I would like to be able to do the following in the View: <%= contact_email.status = IF there is a value, then display it, if not, show nothing.

    Read the article

  • Rails show view of one model with form for adding one child - nested attributes vs seperate controll

    - by SWR
    I have a basic two tiered model structure: Articles - Comments with one Article having many comments. What is the best way to add a "Add a comment" form to the bottom of the Articles show page? nested_attributes is overkill as I don't want to be able to edit all of the comments on the page, just to add one more. Is the best way even with Rails 2.3 still to make a separate controller and embed a form_for pointing to the other controller into the Articles show view? If so, how do I get validation errors to return to the article display page? I don't want to make a separate comment page/view... thanks

    Read the article

  • How should nested components interact with model in a GUI application?

    - by fig-gnuton
    Broad design/architecture question. If you have nested components in a GUI, what's the most common way for those components to interact with data? For example, let's say a component receives a click on one of its buttons to save data. Should the save request be delegated up that component's ancestors, with the uppermost ancestor ultimately passing the request to a controller? Or are models/datastores in a GUI application typically singletons, so that a component at any level of a hierarchy can directly get/set data? Or is a controller injected as a dependency down the hierarchy of components, so that any given component is only one intermediary away from the datastore/model?

    Read the article

  • Maintaining shared service in ASP.NET MVC Application

    - by kazimanzurrashid
    Depending on the application sometimes we have to maintain some shared service throughout our application. Let’s say you are developing a multi-blog supported blog engine where both the controller and view must know the currently visiting blog, it’s setting , user information and url generation service. In this post, I will show you how you can handle this kind of case in most convenient way. First, let see the most basic way, we can create our PostController in the following way: public class PostController : Controller { public PostController(dependencies...) { } public ActionResult Index(string blogName, int? page) { BlogInfo blog = blogSerivce.FindByName(blogName); if (blog == null) { return new NotFoundResult(); } IEnumerable<PostInfo> posts = postService.FindPublished(blog.Id, PagingCalculator.StartIndex(page, blog.PostPerPage), blog.PostPerPage); int count = postService.GetPublishedCount(blog.Id); UserInfo user = null; if (HttpContext.User.Identity.IsAuthenticated) { user = userService.FindByName(HttpContext.User.Identity.Name); } return View(new IndexViewModel(urlResolver, user, blog, posts, count, page)); } public ActionResult Archive(string blogName, int? page, ArchiveDate archiveDate) { BlogInfo blog = blogSerivce.FindByName(blogName); if (blog == null) { return new NotFoundResult(); } IEnumerable<PostInfo> posts = postService.FindArchived(blog.Id, archiveDate, PagingCalculator.StartIndex(page, blog.PostPerPage), blog.PostPerPage); int count = postService.GetArchivedCount(blog.Id, archiveDate); UserInfo user = null; if (HttpContext.User.Identity.IsAuthenticated) { user = userService.FindByName(HttpContext.User.Identity.Name); } return View(new ArchiveViewModel(urlResolver, user, blog, posts, count, page, achiveDate)); } public ActionResult Tag(string blogName, string tagSlug, int? page) { BlogInfo blog = blogSerivce.FindByName(blogName); if (blog == null) { return new NotFoundResult(); } TagInfo tag = tagService.FindBySlug(blog.Id, tagSlug); if (tag == null) { return new NotFoundResult(); } IEnumerable<PostInfo> posts = postService.FindPublishedByTag(blog.Id, tag.Id, PagingCalculator.StartIndex(page, blog.PostPerPage), blog.PostPerPage); int count = postService.GetPublishedCountByTag(tag.Id); UserInfo user = null; if (HttpContext.User.Identity.IsAuthenticated) { user = userService.FindByName(HttpContext.User.Identity.Name); } return View(new TagViewModel(urlResolver, user, blog, posts, count, page, tag)); } } As you can see the above code heavily depends upon the current blog and the blog retrieval code is duplicated in all of the action methods, once the blog is retrieved the same blog is passed in the view model. Other than the blog the view also needs the current user and url resolver to render it properly. One way to remove the duplicate blog retrieval code is to create a custom model binder which converts the blog from a blog name and use the blog a parameter in the action methods instead of the string blog name, but it only helps the first half in the above scenario, the action methods still have to pass the blog, user and url resolver etc in the view model. Now lets try to improve the the above code, first lets create a new class which would contain the shared services, lets name it as BlogContext: public class BlogContext { public BlogInfo Blog { get; set; } public UserInfo User { get; set; } public IUrlResolver UrlResolver { get; set; } } Next, we will create an interface, IContextAwareService: public interface IContextAwareService { BlogContext Context { get; set; } } The idea is, whoever needs these shared services needs to implement this interface, in our case both the controller and the view model, now we will create an action filter which will be responsible for populating the context: public class PopulateBlogContextAttribute : FilterAttribute, IActionFilter { private static string blogNameRouteParameter = "blogName"; private readonly IBlogService blogService; private readonly IUserService userService; private readonly BlogContext context; public PopulateBlogContextAttribute(IBlogService blogService, IUserService userService, IUrlResolver urlResolver) { Invariant.IsNotNull(blogService, "blogService"); Invariant.IsNotNull(userService, "userService"); Invariant.IsNotNull(urlResolver, "urlResolver"); this.blogService = blogService; this.userService = userService; context = new BlogContext { UrlResolver = urlResolver }; } public static string BlogNameRouteParameter { [DebuggerStepThrough] get { return blogNameRouteParameter; } [DebuggerStepThrough] set { blogNameRouteParameter = value; } } public void OnActionExecuting(ActionExecutingContext filterContext) { string blogName = (string) filterContext.Controller.ValueProvider.GetValue(BlogNameRouteParameter).ConvertTo(typeof(string), Culture.Current); if (!string.IsNullOrWhiteSpace(blogName)) { context.Blog = blogService.FindByName(blogName); } if (context.Blog == null) { filterContext.Result = new NotFoundResult(); return; } if (filterContext.HttpContext.User.Identity.IsAuthenticated) { context.User = userService.FindByName(filterContext.HttpContext.User.Identity.Name); } IContextAwareService controller = filterContext.Controller as IContextAwareService; if (controller != null) { controller.Context = context; } } public void OnActionExecuted(ActionExecutedContext filterContext) { Invariant.IsNotNull(filterContext, "filterContext"); if ((filterContext.Exception == null) || filterContext.ExceptionHandled) { IContextAwareService model = filterContext.Controller.ViewData.Model as IContextAwareService; if (model != null) { model.Context = context; } } } } As you can see we are populating the context in the OnActionExecuting, which executes just before the controllers action methods executes, so by the time our action methods executes the context is already populated, next we are are assigning the same context in the view model in OnActionExecuted method which executes just after we set the  model and return the view in our action methods. Now, lets change the view models so that it implements this interface: public class IndexViewModel : IContextAwareService { // More Codes } public class ArchiveViewModel : IContextAwareService { // More Codes } public class TagViewModel : IContextAwareService { // More Codes } and the controller: public class PostController : Controller, IContextAwareService { public PostController(dependencies...) { } public BlogContext Context { get; set; } public ActionResult Index(int? page) { IEnumerable<PostInfo> posts = postService.FindPublished(Context.Blog.Id, PagingCalculator.StartIndex(page, Context.Blog.PostPerPage), Context.Blog.PostPerPage); int count = postService.GetPublishedCount(Context.Blog.Id); return View(new IndexViewModel(posts, count, page)); } public ActionResult Archive(int? page, ArchiveDate archiveDate) { IEnumerable<PostInfo> posts = postService.FindArchived(Context.Blog.Id, archiveDate, PagingCalculator.StartIndex(page, Context.Blog.PostPerPage), Context.Blog.PostPerPage); int count = postService.GetArchivedCount(Context.Blog.Id, archiveDate); return View(new ArchiveViewModel(posts, count, page, achiveDate)); } public ActionResult Tag(string blogName, string tagSlug, int? page) { TagInfo tag = tagService.FindBySlug(Context.Blog.Id, tagSlug); if (tag == null) { return new NotFoundResult(); } IEnumerable<PostInfo> posts = postService.FindPublishedByTag(Context.Blog.Id, tag.Id, PagingCalculator.StartIndex(page, Context.Blog.PostPerPage), Context.Blog.PostPerPage); int count = postService.GetPublishedCountByTag(tag.Id); return View(new TagViewModel(posts, count, page, tag)); } } Now, the last thing where we have to glue everything, I will be using the AspNetMvcExtensibility to register the action filter (as there is no better way to inject the dependencies in action filters). public class RegisterFilters : RegisterFiltersBase { private static readonly Type controllerType = typeof(Controller); private static readonly Type contextAwareType = typeof(IContextAwareService); protected override void Register(IFilterRegistry registry) { TypeCatalog controllers = new TypeCatalogBuilder() .Add(GetType().Assembly) .Include(type => controllerType.IsAssignableFrom(type) && contextAwareType.IsAssignableFrom(type)); registry.Register<PopulateBlogContextAttribute>(controllers); } } Thoughts and Comments?

    Read the article

  • Getting MySQL work with Entity Framework 4.0

    - by DigiMortal
    Does MySQL work with Entity Framework 4.0? The answer is: yes, it works! I just put up one experimental project to play with MySQL and Entity Framework 4.0 and in this posting I will show you how to get MySQL data to EF. Also I will give some suggestions how to deploy your applications to hosting and cloud environments. MySQL stuff As you may guess you need MySQL running somewhere. I have MySQL installed to my development machine so I can also develop stuff when I’m offline. The other thing you need is MySQL Connector for .NET Framework. Currently there is available development version of MySQL Connector/NET 6.3.5 that supports Visual Studio 2010. Before you start download MySQL and Connector/NET: MySQL Community Server Connector/NET 6.3.5 If you are not big fan of phpMyAdmin then you can try out free desktop client for MySQL – HeidiSQL. I am using it and I am really happy with this program. NB! If you just put up MySQL then create also database with couple of table there. To use all features of Entity Framework 4.0 I suggest you to use InnoDB or other engine that has support for foreign keys. Connecting MySQL to Entity Framework 4.0 Now create simple console project using Visual Studio 2010 and go through the following steps. 1. Add new ADO.NET Entity Data Model to your project. For model insert the name that is informative and that you are able later recognize. Now you can choose how you want to create your model. Select “Generate from database” and click OK. 2. Set up database connection Change data connection and select MySQL Database as data source. You may also need to set provider – there is only one choice. Select it if data provider combo shows empty value. Click OK and insert connection information you are asked about. Don’t forget to click test connection button to see if your connection data is okay. If everything works then click OK. 3. Insert context name Now you should see the following dialog. Insert your data model name for application configuration file and click OK. Click next button. 4. Select tables for model Now you can select tables and views your classes are based on. I have small database with events data. Uncheck the checkbox “Include foreign key columns in the model” – it is damn annoying to get them away from model later. Also insert informative and easy to remember name for your model. Click finish button. 5. Define your classes Now it’s time to define your classes. Here you can see what Entity Framework generated for you. Relations were detected automatically – that’s why we needed foreign keys. The names of classes and their members are not nice yet. After some modifications my class model looks like on the following diagram. Note that I removed attendees navigation property from person class. Now my classes look nice and they follow conventions I am using when naming classes and their members. NB! Don’t forget to see properties of classes (properties windows) and modify their set names if set names contain numbers (I changed set name for Entity from Entity1 to Entities). 6. Let’s test! Now let’s write simple testing program to see if MySQL data runs through Entity Framework 4.0 as expected. My program looks for events where I attended. using(var context = new MySqlEntities()) {     var myEvents = from e in context.Events                     from a in e.Attendees                     where a.Person.FirstName == "Gunnar" &&                             a.Person.LastName == "Peipman"                     select e;       Console.WriteLine("My events: ");       foreach(var e in myEvents)     {         Console.WriteLine(e.Title);     } }   Console.ReadKey(); And when I run it I get the result shown on screenshot on right. I checked out from database and these results are correct. At first run connector seems to work slow but this is only the effect of first run. As connector is loaded to memory by Entity Framework it works fast from this point on. Now let’s see what we have to do to get our program work in hosting and cloud environments where MySQL connector is not installed. Deploying application to hosting and cloud environments If your hosting or cloud environment has no MySQL connector installed you have to provide MySQL connector assemblies with your project. Add the following assemblies to your project’s bin folder and include them to your project (otherwise they are not packaged by WebDeploy and Azure tools): MySQL.Data MySQL.Data.Entity MySQL.Web You can also add references to these assemblies and mark references as local so these assemblies are copied to binary folder of your application. If you have references to these assemblies then you don’t have to include them to your project from bin folder. Also add the following block to your application configuration file. <?xml version="1.0" encoding="utf-8"?> <configuration> ...   <system.data>     <DbProviderFactories>         <add              name=”MySQL Data Provider”              invariant=”MySql.Data.MySqlClient”              description=”.Net Framework Data Provider for MySQL”              type=”MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,                   Version=6.2.0.0, Culture=neutral,                   PublicKeyToken=c5687fc88969c44d”          />     </DbProviderFactories>   </system.data> ... </configuration> Conclusion It was not hard to get MySQL connector installed and MySQL connected to Entity Framework 4.0. To use full power of Entity Framework we used InnoDB engine because it supports foreign keys. It was also easy to query our model. To get our project online we needed some easy modifications to our project and configuration files.

    Read the article

< Previous Page | 98 99 100 101 102 103 104 105 106 107 108 109  | Next Page >