• EntityFramework+WCF


    首先需要在服务对象实例上面添加数据契约[DataContract]和  [DataMember],当然直接在类中修改也可以,但是对于tt模板来说一旦保存以后数据就会重新生成,

    所以得在tt模板中修改

    禁用代理类

    添加对象属性

    //添加引用
    public string UsingDirectives(bool inHeader, bool includeCollections = true)
    {
        return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
            ? string.Format(
                CultureInfo.InvariantCulture,
                "{0}using System;{1}{3}" +
                "{2}",
                inHeader ? Environment.NewLine : "",
                includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
                inHeader ? "" : Environment.NewLine, Environment.NewLine + "using System.Runtime.Serialization;")
            : "";
    }
    //上面没有对齐,加一个tab
    public string Property(EdmProperty edmProperty)
    {
        return string.Format(
            CultureInfo.InvariantCulture,
            "{5}	{0} {1} {2} {{ {3}get; {4}set; }}",
            Accessibility.ForProperty(edmProperty),
            _typeMapper.GetTypeName(edmProperty.TypeUsage),
            _code.Escape(edmProperty),
            _code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
            _code.SpaceAfter(Accessibility.ForSetter(edmProperty)), "[DataMember]" + Environment.NewLine);
    }
    
    //给类添加[DataContract]
    public string EntityClassOpening(EntityType entity)
    {
        return string.Format(
            CultureInfo.InvariantCulture,
            "{4}{0} {1}partial class {2}{3}",
            Accessibility.ForType(entity),
            _code.SpaceAfter(_code.AbstractOption(entity)),
            _code.Escape(entity),
            _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)),
            "[DataContract]" + Environment.NewLine);
    }
  • 相关阅读:
    proguard-rules.pro、混淆、导jar包
    百度地图相关开发
    开发apicloud模块遇到的几个梗
    Android相关概念
    file-downloader相关问题
    Android 线程
    Android Studio Tip of the Day
    NAudio的使用说明
    IT回忆录-2
    IT回忆录-1
  • 原文地址:https://www.cnblogs.com/happygx/p/3474236.html
Copyright © 2020-2023  润新知