public static void SavePost(this XElement post, MarketingDomainModelContainer context) { var postId = Int64.Parse( post.Attribute( "id" ).Value ); var result = context.CraigslistPosts.SingleOrDefault( n => n.PostId == postId ); if( result == null ) { result = new CraigslistPost(); result.Id = Guid.NewGuid(); result.PostId = Int64.Parse( post.Attribute( "id" ).Value ); result.EmailAddress = post.Attribute( "contact" ).Value; result.Title = post.Element( "Title" ).Value; result.PostDate = DateTime.Parse( post.Attribute( "datetime" ).Value.Substring( 0, post.Attribute( "datetime" ).Value.LastIndexOf( " " ) ) ); result.PostsElement = post.ToString(); if(!String.IsNullOrEmpty(result.EmailAddress.Replace(" ",""))) context.CraigslistPosts.AddObject( result ); } }
/// <summary> /// Create a new CraigslistPost object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="postDate">Initial value of the PostDate property.</param> /// <param name="postsElement">Initial value of the PostsElement property.</param> /// <param name="postId">Initial value of the PostId property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="emailAddress">Initial value of the EmailAddress property.</param> public static CraigslistPost CreateCraigslistPost(global::System.Guid id, global::System.DateTime postDate, global::System.String postsElement, global::System.Int64 postId, global::System.String title, global::System.String emailAddress) { CraigslistPost craigslistPost = new CraigslistPost(); craigslistPost.Id = id; craigslistPost.PostDate = postDate; craigslistPost.PostsElement = postsElement; craigslistPost.PostId = postId; craigslistPost.Title = title; craigslistPost.EmailAddress = emailAddress; return craigslistPost; }
/// <summary> /// Deprecated Method for adding a new object to the CraigslistPosts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCraigslistPosts(CraigslistPost craigslistPost) { base.AddObject("CraigslistPosts", craigslistPost); }